Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
I'm programming in PyCharm in Virtual Environment on Win11 on a 12900k
I use 2 modules:
• mp_tst_all.py
• mp_tst_a.py
Details
mp_tst_all.py
import multiprocessingimport platformimport mp_tst_adef run_my_multi(): p_xyz = multiprocessing.Process( target=mp_tst_a.run_main, args=()) # p_... = ... p_xyz.start() # p_... .start() p_xyz.join() # p_... .join() returnif __name__ == '__main__': print('py:', platform.python_version()) run_my_multi()mp_tst_a.py
import multiprocessingimport timeimport platformmain_queue = multiprocessing.Queue()def load_directory(def_queue): content_def = def_queue.get() content_def['load_directory_is_alive'] = True def_queue.put(content_def) # ---- do something ... -------- print('\n' + 'LOAD DIRECTORY:') for x in range(3): time.sleep(.6) print('do something ...') print('\n' + 'LOAD ok' + '\n') content_def = def_queue.get() content_def['load_directory_is_alive'] = False content_def['run_load_file'] = True def_queue.put(content_def) returndef load_files(def_queue): content_def = def_queue.get() run_load_file_i = content_def['run_load_file'] def_queue.put(content_def) # ---- do something ... -------- print('LOAD FILE:') if run_load_file_i: for x in range(3): time.sleep(.6) print('FILE ' + str(x)) print('\n' + 'LOAD ok' + '\n') returndef run_main(): global main_queue content = { 'load_directory_is_alive': None, 'run_load_file': None, 'last_download_date': None } main_queue.put(content) rest = 0.2 # for test, try different values time.sleep(rest) jobs = [] content = main_queue.get() content['last_download_date'] = 'xx.xx.xxxx' main_queue.put(content) time.sleep(rest) # ---- process_1.1: load_directory ----------------------------------- process_1_1 = multiprocessing.Process( target=load_directory, name='load_directory', args=(main_queue, )) jobs.append(process_1_1) process_1_1.start() time.sleep(rest) # ---- do not begin process_2 before process_1.1: load_directory exits while process_1_1.is_alive(): pass time.sleep(rest) # ---- process_2: load_files ----------------------------------------- process_2 = multiprocessing.Process( target=load_files, name='load_files', args=(main_queue, )) jobs.append(process_2) process_2.start() process_1_1.join() process_2.join() returnif __name__ == "__main__": print('py:', platform.python_version()) run_main()Bug
first: with PyCharm
mp_tst_a.py works in py 3.11.0_rc2 and in py 3.10(.7)
but
when mp_tst_a.py is called from mp_tst_all.py there is an error in py 3.11.0_rc2,
however, in py 3.10(.7) it works
the error message varies depending on the 'rest' variable (mp_tst_a.py -> def run_main)
Process load_directory:Traceback (most recent call last): File "C:\...\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\...Python311\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) File "C:\...\mp_test_single_a.py", line 10, in load_directory content_def = def_queue.get() ^^^^^^^^^^^^^^^ File "C:\...\Python311\Lib\multiprocessing\queues.py", line 102, in get with self._rlock: File "C:\...\Python311\Lib\multiprocessing\synchronize.py", line 95, in __enter__ return self._semlock.__enter__() ^^^^^^^^^^^^^^^^^^^^^^^^^**PermissionError: [WinError 5]** Zugriff verweigertProcess load_directory:Traceback (most recent call last): File "C:\...\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\...\Python311\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) File "C:\...\mp_test_single_a.py", line 10, in load_directory content_def = def_queue.get() ^^^^^^^^^^^^^^^ File "C:\...\Python311\Lib\multiprocessing\queues.py", line 102, in get with self._rlock: File "C:\...\Python311\Lib\multiprocessing\synchronize.py", line 98, in __exit__ return self._semlock.__exit__(*args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^**OSError: [WinError 6]** Das Handle ist ungültigsecondly: in Command Prompt Window (cmd) it runs:
C:\...\Python311\Lib\site-packages>mp_tst_all.pypy: 3.11.0rc2LOAD DIRECTORY:do something ...do something ...do something ...LOAD okLOAD FILE:FILE 0FILE 1FILE 2LOAD okC:\...\Python311\Lib\site-packages>is it a bug in 3.11.0_rc2 or do i need to change something in the code ?
Thank you
Metadata
Metadata
Assignees
Labels
Projects
Status
Done