Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

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

Open
markshaule-wf opened this issue Sep 25, 2014 · 0 comments

Comments

@markshaule-wf
Copy link
Contributor

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)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant