Make the UpdatesThread a daemon (closes #60)

This commit is contained in:
Lonami Exo 2017-04-29 10:41:56 +02:00
parent 89326c998a
commit a7595347f3

View File

@ -46,7 +46,8 @@ class MtProtoSender:
self.updates_thread_sleep = None self.updates_thread_sleep = None
self.updates_thread = Thread( self.updates_thread = Thread(
target=self.updates_thread_method, name='UpdatesThread') name='UpdatesThread', daemon=True,
target=self.updates_thread_method)
# The "updates" thread must also be running to make periodic ping requests. # The "updates" thread must also be running to make periodic ping requests.
self.set_updates_thread(running=True) self.set_updates_thread(running=True)
@ -399,7 +400,6 @@ class MtProtoSender:
# Always sleep a bit before each iteration to relax the CPU, # Always sleep a bit before each iteration to relax the CPU,
# since it's possible to early 'continue' the loop to reach # since it's possible to early 'continue' the loop to reach
# the next iteration, but we still should to sleep. # the next iteration, but we still should to sleep.
if self.updates_thread_running:
if self.updates_thread_sleep: if self.updates_thread_sleep:
sleep(self.updates_thread_sleep) sleep(self.updates_thread_sleep)
self.updates_thread_sleep = None self.updates_thread_sleep = None