Workiva / furious

Fast and modular async task library for Google App Engine.
Apache License 2.0
37 stars 39 forks source link

AutoContext - Calling set_event_handler() after adding tasks may not work as desired #150

Open markshaule-wf opened 10 years ago

markshaule-wf commented 10 years ago

This is more of an annoyance, but when using an AutoContext to add tasks in batch, you may get undesired results if you don't set the event handler up front.

So the following may not work - as only your last batch would get a completion checker attached:

with context.new(batch_size=10) as ctx:
    for item in items:
        ctx.add(target=my_func)
    ctx.set_event_handler('complete',  completion_handler)

as a work around, always set the event handler first,

with context.new(batch_size=10) as ctx:
    ctx.set_event_handler('complete',  completion_handler)
    for item in items:
        ctx.add(target=my_func)