Skip to content

Commit

Permalink
New done validation of the future, avoids possible errors with double…
Browse files Browse the repository at this point in the history
… callback calling
  • Loading branch information
joamag committed Mar 14, 2019
1 parent 8eeee52 commit 1d2a0df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/appier/async_old.py
Expand Up @@ -231,6 +231,11 @@ def to_coroutine(callable, *args, **kwargs):
callback = kwargs.get("callback", None)

def callback_wrap(result, *args, **kwargs):
# in case the future is already done there's
# nothing remaining to be done returns immediately
# the callback as not result remain to be set
if future.done(): return

# sets the final result in the associated future
# this should contain the contents coming from
# the callback operation (payload)
Expand Down

0 comments on commit 1d2a0df

Please sign in to comment.