> On Jun 24, 2019, at 4:26 PM, Chengi Liu <chengi.liu...@gmail.com> wrote:
> 
>              t = defer.ensureDeferred(network_get(i))

The meaning of "ensureDeferred" is, "ensure [that this thing, which may be a 
coroutine or Deferred, is a] Deferred".  You don't need to use it with things 
decorated with @inlineCallbacks, only with `async def`; it does nothing in your 
example.

We should really have a more explicit version of this, like a classmethod, 
Deferred.fromCoroutine(), that makes more sense in terms of what context you 
need to use it in.  (The naming here comes from asyncio.ensure_future, but that 
does have the somewhat more explicit loop.create_task to pair with it.)

-glyph

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to