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

Message handler support create_threads flag.

This commit is contained in:
eternnoir 2015-07-04 17:20:29 +08:00
parent 3d678707ac
commit e095a2ffe9

View File

@ -135,7 +135,6 @@ class TeleBot:
def __polling(self): def __polling(self):
print('TeleBot: Started polling.') print('TeleBot: Started polling.')
while not self.__stop_polling: while not self.__stop_polling:
print('Get new')
try: try:
self.get_update() self.get_update()
except Exception as e: except Exception as e:
@ -367,9 +366,12 @@ class TeleBot:
for message in new_messages: for message in new_messages:
for message_handler in self.message_handlers: for message_handler in self.message_handlers:
if self._test_message_handler(message_handler, message): if self._test_message_handler(message_handler, message):
self.worker_pool.put(message_handler['function'], message) if self.create_threads:
# t = threading.Thread(target=message_handler['function'], args=(message,)) self.worker_pool.put(message_handler['function'], message)
# t.start() # t = threading.Thread(target=message_handler['function'], args=(message,))
# t.start()
else:
message_handler['function'](message)
break break