Skip to content

Commit

Permalink
Have the connection close upon Phoenix shutdown...
Browse files Browse the repository at this point in the history
  • Loading branch information
CFSworks committed Nov 3, 2011
1 parent c8db0c3 commit 11f4954
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ def start(self, options):
# Go!
self.connection.connect()
self.kernel.start()
reactor.addSystemEventTrigger('before', 'shutdown', self.kernel.stop)
reactor.addSystemEventTrigger('before', 'shutdown', self.shutdown)

def shutdown(self):
"""Disconnect from the server and kill the kernel."""
self.kernel.stop()
self.connection.disconnect()

def applyMeta(self):
#Applies any static metafields to the connection, such as version,
Expand Down
6 changes: 3 additions & 3 deletions minerutil/RPCProtocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def _request(self):
def stop(self):
"""Stop polling. This LongPoller probably shouldn't be reused."""
self.polling = False
if self.connection:
self.connection.close()
self.connection = None

def _requestComplete(self, response):
try:
Expand Down Expand Up @@ -256,8 +259,6 @@ def disconnect(self):
self.poller.connection.close()
if self.longPoller:
self.longPoller.stop()
if self.longPoller.connection is not None:
self.longPoller.connection.close()
self.longPoller = None

def setMeta(self, var, value):
Expand Down Expand Up @@ -319,7 +320,6 @@ def useAskrate(self, variable):
self.poller.setInterval(askrate)

def handleWork(self, work, pushed=False):

if work is None:
return;

Expand Down

0 comments on commit 11f4954

Please sign in to comment.