Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77c2d5f

Browse files
committed
result work not block
1 parent d74ec5e commit 77c2d5f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

result/result_worker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@ def on_result(self, task, result):
2828
assert 'url' in task, 'need url in task'
2929
return self.resultdb.save(project=task['project'], taskid=task['taskid'], url=task['url'], result=result)
3030

31+
def quit(self):
32+
self._quit = True
33+
3134
def run(self):
3235
while not self._quit:
3336
try:
34-
task, result = self.inqueue.get()
37+
task, result = self.inqueue.get(timeout=1)
3538
if 'taskid' in task and 'project' in task and 'url' in task:
3639
logger.info('result %s:%s %s -> %.30r' % (
3740
task['project'], task['taskid'], task['url'], result))
3841
else:
3942
logger.warning('result UNKNOW -> %.30r' % result)
4043
ret = self.on_result(task, result)
4144
except Queue.Empty as e:
42-
time.sleep(1)
4345
continue
4446
except KeyboardInterrupt:
4547
break

0 commit comments

Comments
 (0)