Bug #99796 Python multiprocessing not working

Submitted: 7 Jun 2020 12:07 Modified: 28 Sep 2022 15:22
Reporter: Jesper Wisborg Krogh Email Updates:
Status: Closed Impact on me:
None 
Category:Shell General / Core Client Severity:S2 (Serious)
Version:8.0.20 OS:Windows
Assigned to: CPU Architecture:Any

[7 Jun 2020 12:07] Jesper Wisborg Krogh
Description:
If you try to use the multiprocessing module in Python mode in MySQL Shell, an error occurs when you try to start the processes:

py> proc.start()
C:\Program Files\MySQL\MySQL Shell 8.0\bin\mysqlsh.exe: unknown option -c

How to repeat:
py> import multiprocessing

py> def run_proc():
 ->     print(f'Hello World')
 ->

py> proc = multiprocessing.Process(target=run_proc)

py> proc.start()
C:\Program Files\MySQL\MySQL Shell 8.0\bin\mysqlsh.exe: unknown option -c

py> proc.join

py> proc.close()

Suggested fix:
If it is deemed impossible to support multiprocessing, at least remove the module, so it is clear that it is not supported.
[7 Jun 2020 12:07] Jesper Wisborg Krogh
The workaround is to use the threading module (and the queue module if you need queues) instead.
[8 Jun 2020 12:32] MySQL Verification Team
Dear Jesper,

Thank you for the report and feedback.

regards,
Umesh
[25 Aug 2022 0:20] Alfredo Kojima
Posted by developer:
 
The test case is wrong as it doesn't work in plain python either.
This is a correct test case:

$ cat /tmp/a.py 
import multiprocessing
def run_proc():
    print(f'Hello World')

if __name__ == "__main__":
        proc = multiprocessing.Process(target=run_proc)

        proc.start()
        proc.join()
        proc.close()

$ python3 /tmp/a.py 
Hello World

That said, this bug can be fixed.
[28 Sep 2022 15:22] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Shell 8.0.31 release notes:

Support was added for Python modules which invoke the Python interpreter, such as multiprocessing.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.