Wait 0.1s for new tasks before shut down worker

This commit is contained in:
shortcutme 2017-10-13 01:23:26 +02:00
parent 60af54a17e
commit 027ee83c6f
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -28,7 +28,10 @@ class Worker(object):
while self.running:
# Try to pickup free file download task
task = self.manager.getTask(self.peer)
if not task: # Die, no more task
if not task: # No more task
time.sleep(0.1) # Wait a bit for new tasks
task = self.manager.getTask(self.peer)
if not task: # Still no task, stop it
self.manager.log.debug("%s: No task found, stopping" % self.key)
break
if not task["time_started"]: