aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-09 15:15:50 +0100
committerGravatar jesopo2019-06-09 15:15:50 +0100
commitb782657b69b912cd5c1f5af0c327be3aec3bd640 (patch)
tree8e917c2b5a9be1e214f1cb1cb4631d276da01b70 /modules
parentPut responsbility of `self.running = False` on to the event loop (diff)
signature
manage tweet thread ourselves to make sure it's a daemon
Diffstat (limited to 'modules')
-rw-r--r--modules/tweets/__init__.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/tweets/__init__.py b/modules/tweets/__init__.py
index 688c2b06..edc4fcd2 100644
--- a/modules/tweets/__init__.py
+++ b/modules/tweets/__init__.py
@@ -5,7 +5,7 @@
#--require-config twitter-access-token
#--require-config twitter-access-secret
-import json, re
+import json, re, threading
from src import ModuleManager, utils
from . import format
import tweepy
@@ -45,6 +45,8 @@ class BitBotStreamListener(tweepy.StreamListener):
class Module(ModuleManager.BaseModule):
_stream = None
def on_load(self):
+ self._thread = None
+
global _bot
global _events
global _exports
@@ -94,7 +96,10 @@ class Module(ModuleManager.BaseModule):
self._stream = tweepy.Stream(auth=auth, listener=BitBotStreamListener())
- self._stream.filter(follow=user_ids, is_async=True)
+ self._thread = threading.Thread(
+ target=lambda: self._stream.filter(follow=user_ids))
+ self._thread.daemon = True
+ self._thread.start()
return True
@utils.hook("received.command.tfollow", min_args=2, channel_only=True)