Restart twitter forwarder in thread. (#2045)

This commit is contained in:
Jonathan Zernik 2022-03-28 14:23:13 -07:00 committed by GitHub
parent f12957d25b
commit 8b2ef3ca4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -422,7 +422,7 @@ class SqueakController:
profile_id,
bearer_token,
)
self.update_twitter_stream()
self.tweet_forwarder.restart()
return twitter_account_id
def get_twitter_accounts(self) -> List[TwitterAccountEntry]:
@ -438,7 +438,4 @@ class SqueakController:
def delete_twitter_account(self, twitter_account_id: int) -> None:
self.squeak_store.delete_twitter_account(twitter_account_id)
self.update_twitter_stream()
def update_twitter_stream(self) -> None:
self.tweet_forwarder.start_processing()
self.tweet_forwarder.restart()

View file

@ -43,6 +43,12 @@ class TwitterForwarder:
self.lock = threading.Lock()
self.current_tasks: Dict[str, TwitterForwarderTask] = {}
def restart(self):
threading.Thread(
target=self.start_processing,
daemon=True,
).start()
def start_processing(self):
with self.lock:
# Stop existing running tasks.