1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Integrated blocking into polling + updated docs

This commit is contained in:
97Pedrito
2015-08-30 18:53:18 +02:00
parent e4bb2ff4f9
commit c33c116488
2 changed files with 13 additions and 20 deletions

View File

@ -136,7 +136,7 @@ class TeleBot:
else:
listener(new_messages)
def polling(self, none_stop=False, interval=0):
def polling(self, none_stop=False, interval=0, block=True):
"""
This function creates a new Thread that calls an internal __polling function.
This allows the bot to retrieve Updates automagically and notify listeners and message handlers accordingly.
@ -155,6 +155,10 @@ class TeleBot:
self.polling_thread.daemon = True
self.polling_thread.start()
if block:
self.__stop_polling.wait()
def __polling(self, none_stop, interval):
logger.info('TeleBot: Started polling.')
while not self.__stop_polling.wait(interval):