Message246420
> *If* it needs to be added I like call_in_thread().
Except if you explicitly set the executor to a thread pool executor, the function name can be a lie. It's possible to modify the default executor to a process poll executor.
I vote -1 for the function. I would prefer to use directly event loop methods (run_in_executor).
# Call blocking operation from asynchronous code
def blocking_call(f, *args, **kwds):
...
This function name is very misleading. Calling blocking_call() doesn't return the result of f(*args, **kwds) but a Future object...
> 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.
I don't like the idea of hiding asyncio complexity. See eventlet monkey patching, it was a big mistake.
But ok to add helpers when they are revelant.
I also fear adding too many functions to do the same things.
For example, scheduling the execution of a coroutine can now be done by:
* asyncio.async(coro)
* asyncio.Task(coro)
* loop.create_task(coro)
* asyncio.ensure_task(coro) |
|
Date |
User |
Action |
Args |
2015-07-07 15:36:17 | vstinner | set | recipients:
+ vstinner, gvanrossum, ncoghlan, pitrou, giampaolo.rodola, yselivanov, srkunze |
2015-07-07 15:36:17 | vstinner | set | messageid: <1436283377.54.0.138659712605.issue24571@psf.upfronthosting.co.za> |
2015-07-07 15:36:17 | vstinner | link | issue24571 messages |
2015-07-07 15:36:17 | vstinner | create | |
|