A Deferred represents the result of a query that may be available (now or in the future), but so far definitely not available.
Results pass through Deferred s through the callback chain. For example, in a synchronous program, you might have something like:
response_bytes = make_request(...) response_dict = parse_json(response_bytes) response_object = construct_object(response_dict) return response_object.method()
The translated code that Deferred returns is:
response_bytes_later = make_request_async(...) response_dict_later = response_bytes_later.addCallback(parse_json) response_object_later = response_dict_later.addCallback(construct_object) return response_object_later.addCallback(lambda response_object: response_object.method())
Asking why you cannot start (or βcall backβ), Deferred returned by make_request_async is like asking why you cannot return make_request several times to cause a callback. If you want to resubmit the request in the synchronous version, you need to call make_request again (and get a new result). If you want to send the request again in the asynchronous version, you need to call make_request_async again (and get a new Deferred ).
Glyph
source share