You need to iterate the generator. Otherwise the generator is not executed.
>>> def gen():
... print(1)
... yield 'blah'
... print(2)
...
>>> g = gen() # No print (not executed)
>>> next(g) # print 1, yield `blah`. execution suspended.
1
'blah'
Replace following line:
worker.dispatch(res)
with:
for rs in worker.dispatch(res):
pass
or
next(worker.dispatch(res))