Re: Running CPU bound function concurrently in twisted
Glyph <[email protected]> Mon, 24 Jun 2019 21:08:27 -0700
| Newsgroups | gmane.comp.python.twisted |
|---|---|
| Message-ID | <[email protected]> |
> On Jun 24, 2019, at 4:26 PM, Chengi Liu <[email protected]> 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 [email protected] https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python