homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients giampaolo.rodola, gvanrossum, ncoghlan, pitrou, vstinner, yselivanov
Date 2015年07月06日.01:36:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1436146594.33.0.331638937124.issue24571@psf.upfronthosting.co.za>
In-reply-to
Content
Based on a current python-dev discussion, I'd like to suggest a high level convenience API in asyncio to dispatch a blocking call out to a separate thread or process:
 # Call blocking operation from asynchronous code
 def blocking_call(f, *args, **kwds):
 """Usage: result = await asyncio.blocking_call(f, *args, **kwds))"""
 cb = functools.partial(f, *args, **kwds)
 return asyncio.get_event_loop().run_in_executor(cb)
While that function is only a couple of lines long, it's *conceptually* very dense.
The aim would thus be to let folks safely make blocking calls from asyncio code without needing to first understand the intricacies of the event loop, the event loop's executor, or the need to wrap the call in functools.partial. Exploring those would instead become an optional exercise in understanding how asyncio.blocking_call works.
History
Date User Action Args
2015年07月06日 01:36:34ncoghlansetrecipients: + ncoghlan, gvanrossum, pitrou, vstinner, giampaolo.rodola, yselivanov
2015年07月06日 01:36:34ncoghlansetmessageid: <1436146594.33.0.331638937124.issue24571@psf.upfronthosting.co.za>
2015年07月06日 01:36:34ncoghlanlinkissue24571 messages
2015年07月06日 01:36:32ncoghlancreate

AltStyle によって変換されたページ (->オリジナル) /