python / cpython

The Python programming language
https://www.python.org
Other
62.68k stars 30.06k forks source link

Make concurrent.futures.Future usable outside of executors #89528

Open 50b270af-29d1-4e60-929e-94b6a6a5e3f6 opened 2 years ago

50b270af-29d1-4e60-929e-94b6a6a5e3f6 commented 2 years ago
BPO 45365
Nosy @masklinn

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['type-feature', 'library', '3.11'] title = 'Make concurrent.futures.Future usable outside of executors' updated_at = user = 'https://github.com/masklinn' ``` bugs.python.org fields: ```python activity = actor = 'terry.reedy' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'xmorel' dependencies = [] files = [] hgrepos = [] issue_num = 45365 keywords = [] message_count = 1.0 messages = ['403181'] nosy_count = 1.0 nosy_names = ['xmorel'] pr_nums = [] priority = 'normal' resolution = None stage = 'test needed' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue45365' versions = ['Python 3.11'] ```

50b270af-29d1-4e60-929e-94b6a6a5e3f6 commented 2 years ago

concurrent.futures.Future currently has the note:

Future instances are created by Executor.submit() and should not be created directly except for testing.

That seems like a shame as futures are useful concurrency construct and having to rebuild them "by hand" seems like a waste.

What are the issues which prevent safely using futures outside of executors, and is there a way they could be fixed / lifted?

python-ast-person commented 2 years ago

As far as I know, they are safe to use outside of an Executor, it's just almost all of the intended use cases were in Executor implementations.