Repository navigation
Nested multiprocessing leads to AttributeError: is_fork_ctx with forkserver or spawn methods #108520
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Aug 26, 2023 Sorry about that, proposed a fix at #108568
Just to add confirmation to what has already been documented here and to document for others using the gcloud cli and finding this in search, I'm on python3.11.5 as well (
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)]) and am encountering this error with thegcloudcli tools.A search for the following error message brought me here:
$ gcloud storage cp gs://bucket/file ./ --verbosity debug DEBUG: Running [gcloud.storage.cp] with arguments: [--verbosity: "debug", DESTINATION: "./", SOURCE:1: "['gs://bucket/file']"] DEBUG: Starting new HTTPS connection (1): storage.googleapis.com:443 DEBUG: https://storage.googleapis.com:443 "GET /storage/v1/b/bucket/o/data%2Ffile?alt=json&projection=noAcl HTTP/1.1" 200 896 Copying gs://bucket/file to file://./file INFO: Using high CPU count, single-file workload config. ⠛ERROR: gcloud crashed (AttributeError): 'Lock' object has no attribute 'is_fork_ctx'
This happens regardless of which gcloud version I upgrade or downgrade to:
$ gcloud version Google Cloud SDK 444.0.0 beta 2023.08.22 bq 2.0.97 core 2023.08.22 gcloud-crc32c 1.0.0 gsutil 5.25And I can successfully execute the command if I tell gcloud to use an older python version before 3.11.5, e.g.:
$ CLOUDSDK_PYTHON=python3.10 gcloud storage cp gs://bucket/file ./ # (executes just fine)Reacted by Benjamin Derksen, martincra, Sam Stoelinga, jayrchamp, Lazhar, Reza Qorbani and Vladi Rozen- added a commit that references this issue
on Aug 30, 2023 - added a commit that references this issue
on Aug 30, 2023 - added a commit that references this issue
on Aug 30, 2023 - added a commit that references this issue
on Aug 30, 2023 The fix appears to be merged and backported. Shouldn't this be closed?
Hmm, interesting. I thought that the auto-merge feature would also auto-close the issue, but it didn't.
It doesn't seem like a fix has been released for Mac yet. I'm still hitting this issue after running
brew upgradesince it's still using python 3.11.5. I did confirm the workaround provided by @carbocation works correctly.Correct, the fix version will be 3.11.6 which doesn't exist yet.
looks like python3.11.6 was released today. I haven't tested the fix since I'm waiting for
brewto support it (to keep my installations manageable).I can confirm that the problem no longer occurs with python 3.11.6 (tested with
Google Cloud SDK 446.0.1onMacOS 13.4). I had the issue with python 3.11.5Reacted by albanD
Bug report
Checklist
and am confident this bug has not been reported before
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.11.5 (main, Aug 26 2023, 00:26:34) [GCC 12.2.1 20220924]
A clear and concise description of the bug:
Using nested
multiprocessing(i.e. spawn a child process inside a child process) is broken as of Python 3.11.5, leading to an attribute error.Minimal code example below. Invoke with argument
fork,forkserverorspawn.forkwill work.forkserverandspawnwill both raise the above error. All three variants work with Python 3.11.4.I believe that the source of this regression is 34ef75d which adds the attribute
is_fork_ctxtomultiprocessing.Lock()but doesn't update the pickle methods (__getstate__()and__setstate__()) so after being serialised and deserialised, theLock()object looses that attribute.The following patch, adding
is_fork_ctxto the pickle methods, makes the above work again.Linked PRs