summaryrefslogtreecommitdiff
path: root/redis
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2016-05-17 17:43:33 -0400
committerAndy McCurdy <andy@andymccurdy.com>2016-05-17 17:43:33 -0400
commit5ef18fd517a50ec04a0a8db353fdba2872c47d61 (patch)
treef8417caca2a09cd8524d97c0a2fe4433efe4f98d /redis
parent273a47e299a499ed0053b8b90966dc2124504983 (diff)
parent226b290ac22abcde92f52d5ace94c219834d4f98 (diff)
downloadredis-py-5ef18fd517a50ec04a0a8db353fdba2872c47d61.tar.gz
Merge pull request #737 from hulu/master
add daemon option to PubSubWorker so ctrl-c will work
Diffstat (limited to 'redis')
-rwxr-xr-xredis/client.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py
index 5f86b1d..8ac8b9b 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -2362,7 +2362,7 @@ class PubSub(object):
return message
- def run_in_thread(self, sleep_time=0):
+ def run_in_thread(self, sleep_time=0, daemon=False):
for channel, handler in iteritems(self.channels):
if handler is None:
raise PubSubError("Channel: '%s' has no handler registered")
@@ -2370,14 +2370,15 @@ class PubSub(object):
if handler is None:
raise PubSubError("Pattern: '%s' has no handler registered")
- thread = PubSubWorkerThread(self, sleep_time)
+ thread = PubSubWorkerThread(self, sleep_time, daemon=daemon)
thread.start()
return thread
class PubSubWorkerThread(threading.Thread):
- def __init__(self, pubsub, sleep_time):
+ def __init__(self, pubsub, sleep_time, daemon=False):
super(PubSubWorkerThread, self).__init__()
+ self.daemon = daemon
self.pubsub = pubsub
self.sleep_time = sleep_time
self._running = False