mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 09:53:45 +03:00
Warn users on .add_update_handler if no workers are running (#300)
This commit is contained in:
parent
91a5d20e93
commit
7b5d409c49
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
import warnings
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
@ -742,6 +743,9 @@ class TelegramBareClient:
|
||||||
def add_update_handler(self, handler):
|
def add_update_handler(self, handler):
|
||||||
"""Adds an update handler (a function which takes a TLObject,
|
"""Adds an update handler (a function which takes a TLObject,
|
||||||
an update, as its parameter) and listens for updates"""
|
an update, as its parameter) and listens for updates"""
|
||||||
|
if not self.updates.get_workers:
|
||||||
|
warnings.warn("There are no update workers running, so adding an update handler will have no effect.")
|
||||||
|
|
||||||
sync = not self.updates.handlers
|
sync = not self.updates.handlers
|
||||||
self.updates.handlers.append(handler)
|
self.updates.handlers.append(handler)
|
||||||
if sync:
|
if sync:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user