Added order token infrastructure and fixed most issues with late-arriving results

This commit is contained in:
Sumner Evans
2020-02-20 13:44:37 -07:00
parent 227309d600
commit 916e190bac
9 changed files with 222 additions and 70 deletions

View File

@@ -319,7 +319,14 @@ def async_callback(
"""
def decorator(callback_fn):
@functools.wraps(callback_fn)
def wrapper(self, *args, state=None, **kwargs):
def wrapper(
self,
*args,
state=None,
order_token=None,
force=False,
**kwargs,
):
if before_download:
on_before_download = (
lambda: GLib.idle_add(before_download, self))
@@ -334,11 +341,19 @@ def async_callback(
on_failure(self, e)
return
return GLib.idle_add(callback_fn, self, result, state)
return GLib.idle_add(
lambda: callback_fn(
self,
result,
state=state,
force=force,
order_token=order_token,
))
future: Future = future_fn(
*args,
before_download=on_before_download,
force=force,
**kwargs,
)
future.add_done_callback(future_callback)