Vincent Michel added the comment: While I was working on the documentation update, I realized that what we called `run_coroutine_threadsafe` is actually a thread-safe version of `ensure_future`. What about renaming it to `ensure_future_threadsafe`? It might be a bit late since `run_coroutine_threadsafe` has been committed, but I think it is worth to be considered. I can see two benefits:
- it is less confusing, because it has the same name and using the same prototype as `ensure_future` - it accepts futures and awaitables The docstring would be "Wrap a coroutine, an awaitable or a future in a concurrent.futures.Future.". The documentation would explain that it works like `ensure_future` except: 1. its execution is threadsafe 2. it provides a thread-safe future instead of a regular future I attached an implementation of it. Also, note that I added a `try-except` in the callback, which is not mandatory but probably a good thing have. In any case, I'll keep working on the documentation update. ---------- Added file: http://bugs.python.org/file40672/ensure_future_threadsafe.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25304> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com