ID 518944 - concurrent.futures Python module doesn't work in Nuke, causing Nuke to error or not print correctly

Follow

Problem summary
concurrent.futures Python module doesn't work in Nuke, causing Nuke to error or not print correctly
 
Windows errors, while Linux and macOS run the command, however all of them hang while running, not executing in a background thread
 
Customer reported version
nuke.13.2v2
 
Customer reported platform
windows10
 
Steps to reproduce
 
1) Open Nuke

2) In the Script Editor, run the following code:
 

import concurrent.futuresimport timefrom random import randomdef do_work_and_return():    time_waiting = random() * 10.0    time.sleep(time_waiting)    return time_waitingdef callback(future):    print(future.result())def main():    with concurrent.futures.ProcessPoolExecutor() as executor:        task = executor.submit(do_work_and_return)        task.add_done_callback(callback)        for i in range(10):            time.sleep(1)            print(i)if __name__ == '__main__':    main()
 
Expected behaviour
For the Script Editor to print the numbers 0-9, with a 1 second gap, and randomly print another number during that time:


 
Actual behaviour
On Windows Nuke hangs for a while then prints all the numbers at once along with errors these errors in the Script Editor: 
 
Exception ignored in: <function ProcessPoolExecutor._start_queue_management_thread.<locals>.weakref_cb at 0x00000270EBC6F8B8> Traceback (most recent call last):   File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\process.py", line 581, in weakref_cb     thread_wakeup.wakeup()   File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\process.py", line 90, in wakeup     self._writer.send_bytes(b"")   File "C:\Program Files\Nuke13.2v4\lib\multiprocessing\connection.py", line 183, in send_bytes     self._check_closed()   File "C:\Program Files\Nuke13.2v4\lib\multiprocessing\connection.py", line 136, in _check_closed     raise OSError("handle is closed") OSError: handle is closed ERROR 15:13:25.483:concurrent.futures(37984): exception calling callback for <Future at 0x27082e8d1c8 state=finished raised BrokenProcessPool> Traceback (most recent call last):   File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 324, in _invoke_callbacks     callback(self)   File "<string>", line 11, in callback   File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 428, in result     return self.__get_result()   File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 384, in __get_result     raise self._exception concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending. 
 

 
And these errors in the Command Prompt:
Unknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidUnknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidUnknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidUnknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidUnknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidERROR 15:08:07.400:concurrent.futures(37984): exception calling callback for <Future at 0x270ebc6a608 state=finished raised BrokenProcessPool>Traceback (most recent call last):  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 324, in _invoke_callbacks    callback(self)  File "<string>", line 11, in callback  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 428, in result    return self.__get_result()  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 384, in __get_result    raise self._exceptionconcurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.Exception ignored in: <function ProcessPoolExecutor._start_queue_management_thread.<locals>.weakref_cb at 0x00000270EBC6F948>Traceback (most recent call last):  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\process.py", line 581, in weakref_cb    thread_wakeup.wakeup()  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\process.py", line 90, in wakeup    self._writer.send_bytes(b"")  File "C:\Program Files\Nuke13.2v4\lib\multiprocessing\connection.py", line 183, in send_bytes    self._check_closed()  File "C:\Program Files\Nuke13.2v4\lib\multiprocessing\connection.py", line 136, in _check_closed    raise OSError("handle is closed")OSError: handle is closedUnknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidUnknown units in -c from multiprocessing.spawn import spawn_main; spawn_main(parent_pidERROR 15:13:25.483:concurrent.futures(37984): exception calling callback for <Future at 0x27082e8d1c8 state=finished raised BrokenProcessPool>Traceback (most recent call last):  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 324, in _invoke_callbacks    callback(self)  File "<string>", line 11, in callback  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 428, in result    return self.__get_result()  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\_base.py", line 384, in __get_result    raise self._exceptionconcurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.Exception ignored in: <function ProcessPoolExecutor._start_queue_management_thread.<locals>.weakref_cb at 0x00000270EBC6F8B8>Traceback (most recent call last):  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\process.py", line 581, in weakref_cb    thread_wakeup.wakeup()  File "C:\Program Files\Nuke13.2v4\lib\concurrent\futures\process.py", line 90, in wakeup    self._writer.send_bytes(b"")  File "C:\Program Files\Nuke13.2v4\lib\multiprocessing\connection.py", line 183, in send_bytes    self._check_closed()  File "C:\Program Files\Nuke13.2v4\lib\multiprocessing\connection.py", line 136, in _check_closed    raise OSError("handle is closed")OSError: handle is closed

 
On Linux and macOS, Nuke hangs for 10 seconds, then prints all the numbers at once:
 

 
Workaround
None
 
Reproduced by support
This bug has been reproduced in:
Nuke 13.2v4 - Windows 10, CentOS 7, macOS 12.5
Nuke 13.0v1 - Windows 10
 
Earliest version tested
Nuke 13.0v1 - concurrent.futures module doesn't exist in Python 2
 
 

    We're sorry to hear that

    Please tell us why