Skip to content
This repository was archived by the owner on Dec 21, 2025. It is now read-only.

Commit e85889e

Browse files
committed
removed run_in_executor
1 parent 751b0d3 commit e85889e

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ may have moved code there. Many features of Curio were simply
1010
higher-level modules implemented on top of an existing core and can be
1111
added back to your code without much effort. -- Dave
1212

13+
04/10/2024 Removed run_in_executor(). If you want to wait on work
14+
submitted to a traditional executor (from concurrent.futures),
15+
use curio.traps._future_wait().
16+
1317
04/10/2024 Removed subprocess module. Use the Python built-in instead.
1418
Old code found in examples/curio_subprocess.py
1519

curio/workers.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# running functions in threads, processes, and executors from the
55
# concurrent.futures module.
66

7-
__all__ = ['run_in_executor', 'run_in_thread', 'run_in_process', 'block_in_thread']
7+
__all__ = ['run_in_thread', 'run_in_process', 'block_in_thread']
88

99
# -- Standard Library
1010

@@ -52,23 +52,6 @@ def rebuild_exc(exc, tb):
5252
exc.__cause__ = RemoteTraceback(tb)
5353
return exc
5454

55-
async def run_in_executor(exc, callable, *args):
56-
'''
57-
Run callable(*args) in an executor such as
58-
ThreadPoolExecutor or ProcessPoolExecutor from the
59-
concurrent.futures module. Be aware that on cancellation, any
60-
worker thread or process that was handling the request will
61-
continue to run to completion as a kind of zombie-- possibly
62-
rendering the executor unusable for subsequent work.
63-
64-
This function is provided for compatibility with
65-
concurrent.futures, but is not the recommend approach for running
66-
blocking or cpu-bound work in curio. Use the run_in_thread() or
67-
run_in_process() methods instead.
68-
'''
69-
future = exc.submit(callable, *args)
70-
await _future_wait(future)
71-
return future.result()
7255

7356
MAX_WORKER_THREADS = 64
7457

tests/test_workers.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ async def main():
7575
'sleep done',
7676
]
7777

78-
def test_executor(kernel):
79-
from concurrent.futures import ThreadPoolExecutor
80-
pool = ThreadPoolExecutor()
81-
async def main():
82-
r = await run_in_executor(pool, fib, 1)
83-
assert r == 1
84-
kernel.run(main())
85-
8678
@pytest.mark.parametrize('runner', [run_in_thread, run_in_process ])
8779
def test_worker_cancel(kernel, runner):
8880
results = []

0 commit comments

Comments
 (0)