diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-05-19 15:27:30 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-05-19 15:05:25 +0000 |
commit | 0558e173e9d3b27fb7dc363e306eaf5109511729 (patch) | |
tree | b9a4901704fd108a79268416967ae5c90638620f /gear | |
parent | bb681360fcbcbb9a9b53f7e0fc02a752996a3cf3 (diff) | |
download | gear-0558e173e9d3b27fb7dc363e306eaf5109511729.tar.gz |
Handle SIGINT correctly in Client.waitForServer()
The Python 2.7 threading.Condition.wait() function will block the
process from responding to any signals until the condition triggers.
This was especially bad for commandline applications. Before this
commit, if an application didn't manage to connect to the Gearman server
it would block forever and ignore CTRL+C.
Adding a 'timeout' works around this issue. Behaviour is unchanged
except that the 'Waiting for at least one active connection' debug
message will now be logged once per second.
This problem is fixed upstream in Python 3.2:
<https://bugs.python.org/issue8844>
Change-Id: Ib1043948b1b37a4a6732176314b8a243aad73397
Diffstat (limited to 'gear')
-rw-r--r-- | gear/__init__.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gear/__init__.py b/gear/__init__.py index 51c0c91..b19d386 100644 --- a/gear/__init__.py +++ b/gear/__init__.py @@ -1196,7 +1196,7 @@ class BaseClient(BaseClientServer): self.connections_condition.acquire() while self.running and not self.active_connections: self.log.debug("Waiting for at least one active connection") - self.connections_condition.wait() + self.connections_condition.wait(timeout=1) if self.active_connections: self.log.debug("Active connection found") connected = True |