From 7b5d409c49e3756d3f9b1d1199eee9c9923f17a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joscha=20G=C3=B6tzer?= Date: Sat, 7 Oct 2017 17:55:37 +0200 Subject: [PATCH] Warn users on .add_update_handler if no workers are running (#300) --- telethon/telegram_bare_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/telethon/telegram_bare_client.py b/telethon/telegram_bare_client.py index 17e8a364..cda8e2ab 100644 --- a/telethon/telegram_bare_client.py +++ b/telethon/telegram_bare_client.py @@ -1,6 +1,7 @@ import logging import os import threading +import warnings from datetime import timedelta, datetime from hashlib import md5 from io import BytesIO @@ -742,6 +743,9 @@ class TelegramBareClient: def add_update_handler(self, handler): """Adds an update handler (a function which takes a TLObject, 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 self.updates.handlers.append(handler) if sync: