Permalink
Browse files

Have the connection close upon Phoenix shutdown...

  • Loading branch information...
1 parent c8db0c3 commit 11f4954675f7969e3337a6559d5e05ea7b888df6 @CFSworks CFSworks committed Nov 3, 2011
Showing with 9 additions and 4 deletions.
  1. +6 −1 Miner.py
  2. +3 −3 minerutil/RPCProtocol.py
View
7 Miner.py
@@ -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,
View
6 minerutil/RPCProtocol.py
@@ -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:
@@ -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):
@@ -319,7 +320,6 @@ def useAskrate(self, variable):
self.poller.setInterval(askrate)
def handleWork(self, work, pushed=False):
-
if work is None:
return;

0 comments on commit 11f4954

Please sign in to comment.