summaryrefslogtreecommitdiff
path: root/distbuild
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-06-05 10:30:18 (GMT)
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-06-10 16:53:45 (GMT)
commit13edeabd929b094ab2ec7288840e62d31d9feb67 (patch)
tree4a0b2f926fd9c229c99528ff451b676e211f0e9a /distbuild
parent60776a0d1956b50e75c9f361218fef955c265d9c (diff)
downloadmorph-13edeabd929b094ab2ec7288840e62d31d9feb67.tar.gz
Fix: force select to wait on timeout
Currently the mainloop unintentionally busy-waits if we can't connect to the controller. We want the mainloop's select call to wait for the timeout not for this socket's descriptors (which are always ready). We could just call stop_reading() and stop_writing() but since we won't be needing this socket again we may as well close the entire event source, which calls stop_reading(), stop_writing() and then closes the socket.
Diffstat (limited to 'distbuild')
-rw-r--r--distbuild/connection_machine.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/distbuild/connection_machine.py b/distbuild/connection_machine.py
index 648ce35..6dec403 100644
--- a/distbuild/connection_machine.py
+++ b/distbuild/connection_machine.py
@@ -118,6 +118,7 @@ class ConnectionMachine(distbuild.StateMachine):
logging.error(
'Failed to connect to %s:%s: %s' %
(self._addr, self._port, str(e)))
+
self.mainloop.queue_event(self, ConnectError())
return
self._sock_proxy.event_source = None
@@ -144,3 +145,5 @@ class ConnectionMachine(distbuild.StateMachine):
def _start_timer(self, event_source, event):
self._timer.start()
+ self._sock_proxy.event_source.close()
+ self._sock_proxy.event_source = None