This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Clint Olsen
Recipients Clint Olsen, asvetlov, yselivanov
Date 2022-01-10.18:55:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When stress testing my code in a process-limited environment I found that despite throwing an exception, it appears the process still executes. Attempting to catch/retry results in a duplicate.

Attached is a script that I was able to repro the problem on Linux. I cannot get it to behave similarly on MacOS.

The exception looks like:

/bin/sh: fork: retry: Resource temporarily unavailable
Traceback (most recent call last):
  File "/home/colsen/async/./example", line 16, in run
    proc = await asyncio.create_subprocess_exec('/bin/sh','-c', f'/bin/echo {_id} > {_uuid}.out')
  File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/", line 236, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/", line 1661, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/", line 202, in _make_subprocess_transport
  File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/", line 1381, in add_child_handler
  File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/", line 892, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

So, this script ended up producing 21 output files (duplicate on iteration 18).

I need a way to catch these errors, pause, and retry when they are recoverable.
Date User Action Args
2022-01-10 18:55:53Clint Olsensetrecipients: + Clint Olsen, asvetlov, yselivanov
2022-01-10 18:55:53Clint Olsensetmessageid: <>
2022-01-10 18:55:53Clint Olsenlinkissue46335 messages
2022-01-10 18:55:53Clint Olsencreate