From 0558e173e9d3b27fb7dc363e306eaf5109511729 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 19 May 2015 15:27:30 +0100 Subject: 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: Change-Id: Ib1043948b1b37a4a6732176314b8a243aad73397 --- gear/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.1