Issue36281
Created on 2019-03-13 17:36 by basnijholt, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg337868 - (view) | Author: Bas Nijholt (basnijholt) | Date: 2019-03-13 17:36 | |
The following code in Python 3.7.1
```
import random
import concurrent.futures
import asyncio
executor = concurrent.futures.ProcessPoolExecutor()
ioloop = asyncio.get_event_loop()
async def func():
result = await ioloop.run_in_executor(executor, random.random)
executor.shutdown(wait=False) # bug doesn't occur when `wait=True`
task = ioloop.create_task(func())
```
prints the following error:
```
Exception in thread QueueManagerThread:
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/opt/conda/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/opt/conda/lib/python3.7/concurrent/futures/process.py", line 368, in _queue_management_worker
thread_wakeup.clear()
File "/opt/conda/lib/python3.7/concurrent/futures/process.py", line 92, in clear
while self._reader.poll():
File "/opt/conda/lib/python3.7/multiprocessing/connection.py", line 255, in poll
self._check_closed()
File "/opt/conda/lib/python3.7/multiprocessing/connection.py", line 136, in _check_closed
raise OSError("handle is closed")
OSError: handle is closed
```
I think this is related to https://bugs.python.org/issue34073 and https://bugs.python.org/issue34075
This happens in the Adaptive package https://adaptive.readthedocs.io/en/latest/docs.html#examples and the related issue is https://github.com/python-adaptive/adaptive/issues/156
|
|||
| msg366116 - (view) | Author: Bas Nijholt (basnijholt) | Date: 2020-04-10 10:58 | |
Using `git bisect` I've discovered the commit (b713adf27a) (https://github.com/python/cpython/commit/b713adf27a) that broke the code. I've used one script: ```test.py import sys sys.path.append("/Users/basnijholt/Downloads/cpython/Lib/concurrent/futures/") from random import random from process import ProcessPoolExecutor import asyncio ioloop = asyncio.get_event_loop() async def func(ioloop, executor): result = await ioloop.run_in_executor(executor, random) executor.shutdown(wait=False) # bug doesn't occur when `wait=True` if __name__ == "__main__": executor = ProcessPoolExecutor() task = ioloop.run_until_complete(func(ioloop, executor)) ``` and `test2.py` ``` import pexpect import sys child = pexpect.spawn("python /Users/basnijholt/Downloads/cpython/test.py") try: child.expect(["OSError", "AssertionError"], timeout=1) raise Exception except pexpect.EOF as e: sys.exit(0) ``` Then did ``` git checkout master git reset --hard 9b6c60cbce # bad commit git bisect start git bisect bad git bisect good ad2c2d380e # good commit git bisect run python test2.py ``` I will see if I can fix it. |
|||
| msg404196 - (view) | Author: Irit Katriel (iritkatriel) * ![]() |
Date: 2021-10-18 16:33 | |
I don't get the error on 3.11, and I think it may have been fixed under Issue39104. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:12 | admin | set | github: 80462 |
| 2021-11-05 19:48:49 | iritkatriel | set | status: pending -> closed stage: resolved |
| 2021-10-18 16:33:41 | iritkatriel | set | status: open -> pending nosy:
+ iritkatriel superseder: ProcessPoolExecutor hangs on shutdown nowait with pickling failure |
| 2020-10-28 21:28:50 | JoeKun | set | nosy:
+ JoeKun |
| 2020-04-10 10:58:09 | basnijholt | set | messages: + msg366116 |
| 2019-03-18 08:30:41 | basnijholt | set | type: crash |
| 2019-03-13 17:36:22 | basnijholt | create | |
