diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-06-05 11:30:18 +0100 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-06-10 17:53:45 +0100 |
commit | 13edeabd929b094ab2ec7288840e62d31d9feb67 (patch) | |
tree | 4a0b2f926fd9c229c99528ff451b676e211f0e9a | |
parent | 60776a0d1956b50e75c9f361218fef955c265d9c (diff) | |
download | morph-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.
-rw-r--r-- | distbuild/connection_machine.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/distbuild/connection_machine.py b/distbuild/connection_machine.py index 648ce35a..6dec403f 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 |