Title: Processes in Python 3.9 exiting with code 1 when It's created inside a ThreadPoolExecutor
Type: behavior Stage:
Components: Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Genarito, davin, pitrou
Priority: normal Keywords:

Created on 2021-04-26 20:59 by Genarito, last changed 2021-04-30 22:15 by terry.reedy.

Messages (1)
msg391985 - (view) Author: Genaro Camele (Genarito) Date: 2021-04-26 20:59
I've a piece of code that submits a task to a [ThreadPoolExecutor][1] which starts a [Process][2]. I've realised that in Python 3.8 that Process finished with exit code `0`. But I've updated Python to the 3.9 version and this started to finishing with exit code `1`! Even when the Process executes an empty task.

Here's a minimal example:

from multiprocessing import Process
from concurrent.futures import ThreadPoolExecutor

def some_task():

def execute_error():
    p = Process(target=some_task)
    print(p.exitcode)  # This is always 1 on a ThreadPoolExecutor!!!

executor = ThreadPoolExecutor(max_workers=4)
# execute_error()  # IMPORTANT: this works correctly (exit 0)

My versions:

Ubuntu 21.04
Python 3.9.4

**Note** that if `__execute_error` is called outside the ThreadPoolExecutor it works correctly.
Running on Python 3.8.6 exitcode = 0 too.

Date User Action Args
2021-04-30 22:15:35terry.reedysetnosy: + pitrou, davin
2021-04-26 20:59:45Genaritocreate