Title: Regression in multiprocessing example using venv on Windows in 3.11rc2 · Issue #98360 · python/cpython · GitHub
Open Graph Title: Regression in multiprocessing example using venv on Windows in 3.11rc2 · Issue #98360 · python/cpython
X Title: Regression in multiprocessing example using venv on Windows in 3.11rc2 · Issue #98360 · python/cpython
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 multiprocessing import platform import mp_tst_a def run_my_multi(): p_xyz = multiprocessin...
Open Graph 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 multiprocessing import platform import mp_tst_a de...
X 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 multiprocessing import platform import mp_tst_...
Opengraph URL: https://github.com/python/cpython/issues/98360
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression in multiprocessing example using venv on Windows in 3.11rc2","articleBody":"I'm programming in PyCharm in Virtual Environment on Win11 on a 12900k\r\n\r\nI use 2 modules:\r\n• mp_tst_all.py\r\n• mp_tst_a.py\r\n\r\n\u003cdetails\u003e\r\n\r\n# mp_tst_all.py\r\n```\r\nimport multiprocessing\r\nimport platform\r\n\r\nimport mp_tst_a\r\n\r\n\r\ndef run_my_multi():\r\n p_xyz = multiprocessing.Process(\r\n target=mp_tst_a.run_main,\r\n args=())\r\n\r\n # p_... = ...\r\n\r\n p_xyz.start()\r\n # p_... .start()\r\n\r\n p_xyz.join()\r\n # p_... .join()\r\n\r\n return\r\n\r\n\r\nif __name__ == '__main__':\r\n\r\n print('py:', platform.python_version())\r\n\r\n run_my_multi()\r\n\r\n```\r\n\r\n# mp_tst_a.py\r\n```\r\nimport multiprocessing\r\nimport time\r\nimport platform\r\n\r\nmain_queue = multiprocessing.Queue()\r\n\r\n\r\ndef load_directory(def_queue):\r\n\r\n content_def = def_queue.get()\r\n content_def['load_directory_is_alive'] = True\r\n def_queue.put(content_def)\r\n\r\n # ---- do something ... --------\r\n print('\\n' + 'LOAD DIRECTORY:')\r\n for x in range(3):\r\n time.sleep(.6)\r\n print('do something ...')\r\n print('\\n' + 'LOAD ok' + '\\n')\r\n\r\n\r\n content_def = def_queue.get()\r\n content_def['load_directory_is_alive'] = False\r\n content_def['run_load_file'] = True\r\n def_queue.put(content_def)\r\n\r\n return\r\n\r\n\r\ndef load_files(def_queue):\r\n\r\n content_def = def_queue.get()\r\n run_load_file_i = content_def['run_load_file']\r\n def_queue.put(content_def)\r\n\r\n # ---- do something ... --------\r\n print('LOAD FILE:')\r\n if run_load_file_i:\r\n for x in range(3):\r\n time.sleep(.6)\r\n print('FILE ' + str(x))\r\n print('\\n' + 'LOAD ok' + '\\n')\r\n\r\n return\r\n\r\n\r\ndef run_main():\r\n\r\n global main_queue\r\n\r\n content = {\r\n 'load_directory_is_alive': None,\r\n 'run_load_file': None,\r\n 'last_download_date': None\r\n }\r\n\r\n main_queue.put(content)\r\n\r\n rest = 0.2 # for test, try different values\r\n time.sleep(rest)\r\n\r\n jobs = []\r\n\r\n content = main_queue.get()\r\n content['last_download_date'] = 'xx.xx.xxxx'\r\n main_queue.put(content)\r\n time.sleep(rest)\r\n\r\n\r\n # ---- process_1.1: load_directory -----------------------------------\r\n process_1_1 = multiprocessing.Process(\r\n target=load_directory, name='load_directory',\r\n args=(main_queue, ))\r\n\r\n jobs.append(process_1_1)\r\n process_1_1.start()\r\n time.sleep(rest)\r\n\r\n\r\n # ---- do not begin process_2 before process_1.1: load_directory exits\r\n while process_1_1.is_alive():\r\n pass\r\n time.sleep(rest)\r\n\r\n\r\n # ---- process_2: load_files -----------------------------------------\r\n process_2 = multiprocessing.Process(\r\n target=load_files, name='load_files',\r\n args=(main_queue, ))\r\n\r\n jobs.append(process_2)\r\n process_2.start()\r\n\r\n\r\n process_1_1.join()\r\n process_2.join()\r\n\r\n return\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\r\n print('py:', platform.python_version())\r\n run_main()\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\r\n# Bug\r\n\r\n**first: with PyCharm**\r\n\r\nmp_tst_a.py works in py 3.11.0_rc2 and in py 3.10(.7)\r\n\r\n**but**\r\n\r\n**when mp_tst_a.py is called from mp_tst_all.py there is an error in py 3.11.0_rc2,**\r\nhowever, in py 3.10(.7) it works\r\n\r\nthe error message varies depending on the 'rest' variable (mp_tst_a.py -\u003e def run_main)\r\n\r\n```\r\nProcess load_directory:\r\nTraceback (most recent call last):\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\process.py\", line 314, in _bootstrap\r\n self.run()\r\n File \"C:\\...Python311\\Lib\\multiprocessing\\process.py\", line 108, in run\r\n self._target(*self._args, **self._kwargs)\r\n File \"C:\\...\\mp_test_single_a.py\", line 10, in load_directory\r\n content_def = def_queue.get()\r\n ^^^^^^^^^^^^^^^\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\queues.py\", line 102, in get\r\n with self._rlock:\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\synchronize.py\", line 95, in __enter__\r\n return self._semlock.__enter__()\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^\r\n**PermissionError: [WinError 5]** Zugriff verweigert\r\n```\r\n\r\n\r\n```\r\nProcess load_directory:\r\nTraceback (most recent call last):\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\process.py\", line 314, in _bootstrap\r\n self.run()\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\process.py\", line 108, in run\r\n self._target(*self._args, **self._kwargs)\r\n File \"C:\\...\\mp_test_single_a.py\", line 10, in load_directory\r\n content_def = def_queue.get()\r\n ^^^^^^^^^^^^^^^\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\queues.py\", line 102, in get\r\n with self._rlock:\r\n File \"C:\\...\\Python311\\Lib\\multiprocessing\\synchronize.py\", line 98, in __exit__\r\n return self._semlock.__exit__(*args)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n**OSError: [WinError 6]** Das Handle ist ungültig\r\n```\r\n\r\n\r\n\r\n**secondly: in Command Prompt Window (cmd) it runs:**\r\n\r\n```\r\nC:\\...\\Python311\\Lib\\site-packages\u003emp_tst_all.py\r\npy: 3.11.0rc2\r\n\r\nLOAD DIRECTORY:\r\ndo something ...\r\ndo something ...\r\ndo something ...\r\n\r\nLOAD ok\r\n\r\nLOAD FILE:\r\nFILE 0\r\nFILE 1\r\nFILE 2\r\n\r\nLOAD ok\r\n\r\n\r\nC:\\...\\Python311\\Lib\\site-packages\u003e\r\n```\r\n\r\n\r\n\r\n**_is it a bug in 3.11.0_rc2 or do i need to change something in the code ?_**\r\n**Thank you**\r\n","author":{"url":"https://github.com/edge-python","@type":"Person","name":"edge-python"},"datePublished":"2022-10-17T17:03:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/98360/cpython/issues/98360"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3eb75ddc-8fe2-6955-7517-7cfd57d11cea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AB4E:26204A:A3AA95:DBE232:696991CE |
| html-safe-nonce | b7b5a3a0e37e9c78cce894fe4b6b751cf5595f190e4ff9f14d8429b9bd4d93c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjRFOjI2MjA0QTpBM0FBOTU6REJFMjMyOjY5Njk5MUNFIiwidmlzaXRvcl9pZCI6IjQ5OTcwMTUzNTkxMTgyMTc2NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 69ee5e6949a655ad6880a335efe433fda29e8eb5551502f52e707f2aee56b581 |
| hovercard-subject-tag | issue:1411913276 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/98360/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a99322dbf9edacdbd16ad52dd3b867b407c05372a349ec204897c04de1d6052b/python/cpython/issues/98360 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a99322dbf9edacdbd16ad52dd3b867b407c05372a349ec204897c04de1d6052b/python/cpython/issues/98360 |
| og:image:alt | 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 multiprocessing import platform import mp_tst_a de... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edge-python |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width