Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-1596321: Fix threading._shutdown() for the main thread #28549

Merged
merged 1 commit into from
Sep 27, 2021
Merged

bpo-1596321: Fix threading._shutdown() for the main thread #28549

merged 1 commit into from
Sep 27, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 24, 2021

Fix the threading._shutdown() function when the threading module was
imported first from a thread different than the main thread: no
longer log an error at Python exit.

https://bugs.python.org/issue1596321

Fix the threading._shutdown() function when the threading module was
imported first from a thread different than the main thread: no
longer log an error at Python exit.
@gpshead gpshead added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Sep 25, 2021
@vstinner vstinner merged commit 95d3137 into python:main Sep 27, 2021
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@vstinner vstinner deleted the thread branch September 27, 2021 21:09
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 27, 2021
…28549)

Fix the threading._shutdown() function when the threading module was
imported first from a thread different than the main thread: no
longer log an error at Python exit.
(cherry picked from commit 95d3137)

Co-authored-by: Victor Stinner <vstinner@python.org>
@miss-islington
Copy link
Contributor

Sorry, @vstinner, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 95d31370829b7d729667588e0a9943217401ea5b 3.9

@bedevere-bot
Copy link

GH-28588 is a backport of this pull request to the 3.10 branch.

@bedevere-bot
Copy link

GH-28589 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Sep 27, 2021
@vstinner
Copy link
Member Author

@gpshead: Thanks for the review. Yeah, moving atexit causes a minor behavior change. I don't think that anyone relies on it.

miss-islington added a commit that referenced this pull request Sep 27, 2021
Fix the threading._shutdown() function when the threading module was
imported first from a thread different than the main thread: no
longer log an error at Python exit.
(cherry picked from commit 95d3137)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Sep 27, 2021
…GH-28589)

Fix the threading._shutdown() function when the threading module was
imported first from a thread different than the main thread: no
longer log an error at Python exit.

(cherry picked from commit 95d3137)
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable 3.9 has failed when building commit 94d19f6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/176/builds/234) and take a look at the build logs.
  4. Check if the failure is related to this commit (94d19f6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/176/builds/234

Failed tests:

  • test_multiprocessing_spawn
  • test_multiprocessing_forkserver
  • test_multiprocessing_fork

Failed subtests:

  • test_shared_memory_basics - test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_spawn.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_fork.WithProcessesTestSharedMemory

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

410 tests OK.

10 slowest tests:

  • test_concurrent_futures: 3 min 4 sec
  • test_gdb: 2 min 47 sec
  • test_multiprocessing_spawn: 2 min 4 sec
  • test_capi: 1 min 58 sec
  • test_peg_generator: 1 min 40 sec
  • test_multiprocessing_forkserver: 1 min 36 sec
  • test_asyncio: 1 min 17 sec
  • test_unparse: 1 min 13 sec
  • test_multiprocessing_fork: 1 min 10 sec
  • test_tokenize: 1 min 8 sec

3 tests failed:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

12 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_startfile
test_tix test_tk test_ttk_guionly test_winconsoleio test_winreg
test_winsound test_zipfile64

3 re-run tests:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

Total duration: 5 min 19 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64/build/Lib/test/_test_multiprocessing.py", line 3774, in test_shared_memory_basics
    sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512)
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64/build/Lib/multiprocessing/shared_memory.py", line 103, in __init__
    self._fd = _posixshmem.shm_open(
FileExistsError: [Errno 17] File exists: '/test01_tsmb'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_5423fe8e'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_0694f074'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_c2b3bb8e'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable Clang 3.9 has failed when building commit 94d19f6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/365/builds/236) and take a look at the build logs.
  4. Check if the failure is related to this commit (94d19f6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/365/builds/236

Failed tests:

  • test_multiprocessing_spawn
  • test_multiprocessing_forkserver
  • test_multiprocessing_fork

Failed subtests:

  • test_shared_memory_basics - test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_spawn.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_fork.WithProcessesTestSharedMemory

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

410 tests OK.

10 slowest tests:

  • test_concurrent_futures: 2 min 36 sec
  • test_peg_generator: 2 min 14 sec
  • test_multiprocessing_spawn: 1 min 37 sec
  • test_multiprocessing_forkserver: 1 min 16 sec
  • test_multiprocessing_fork: 1 min 2 sec
  • test_asyncio: 55.6 sec
  • test_signal: 47.2 sec
  • test_io: 38.3 sec
  • test_socket: 38.3 sec
  • test_tokenize: 32.2 sec

3 tests failed:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

12 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_startfile
test_tix test_tk test_ttk_guionly test_winconsoleio test_winreg
test_winsound test_zipfile64

3 re-run tests:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

Total duration: 3 min 53 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_d6703e79'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_97470b4e'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_d4d7cb75'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang/build/Lib/test/_test_multiprocessing.py", line 3774, in test_shared_memory_basics
    sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512)
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang/build/Lib/multiprocessing/shared_memory.py", line 103, in __init__
    self._fd = _posixshmem.shm_open(
FileExistsError: [Errno 17] File exists: '/test01_tsmb'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable Clang Installed 3.9 has failed when building commit 94d19f6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/17/builds/235) and take a look at the build logs.
  4. Check if the failure is related to this commit (94d19f6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/17/builds/235

Failed tests:

  • test_multiprocessing_spawn
  • test_multiprocessing_forkserver
  • test_multiprocessing_fork

Failed subtests:

  • test_shared_memory_basics - test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_spawn.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_fork.WithProcessesTestSharedMemory

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

406 tests OK.

3 tests failed:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

16 tests skipped:
test_asdl_parser test_check_c_globals test_clinic test_devpoll
test_gdb test_ioctl test_kqueue test_msilib test_startfile
test_tix test_tk test_ttk_guionly test_winconsoleio test_winreg
test_winsound test_zipfile64

3 re-run tests:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

Total duration: 4 min 9 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang-installed/build/target/lib/python3.9/test/_test_multiprocessing.py", line 3774, in test_shared_memory_basics
    sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512)
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang-installed/build/target/lib/python3.9/multiprocessing/shared_memory.py", line 103, in __init__
    self._fd = _posixshmem.shm_open(
FileExistsError: [Errno 17] File exists: '/test01_tsmb'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang-installed/build/target/lib/python3.9/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_509d4859'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang-installed/build/target/lib/python3.9/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_e2f9efdb'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.clang-installed/build/target/lib/python3.9/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_829a7780'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable LTO + PGO 3.9 has failed when building commit 94d19f6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/135/builds/234) and take a look at the build logs.
  4. Check if the failure is related to this commit (94d19f6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/135/builds/234

Failed tests:

  • test_multiprocessing_spawn
  • test_multiprocessing_forkserver
  • test_multiprocessing_fork

Failed subtests:

  • test_shared_memory_basics - test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_spawn.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_fork.WithProcessesTestSharedMemory

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

409 tests OK.

10 slowest tests:

  • test_concurrent_futures: 2 min 38 sec
  • test_multiprocessing_spawn: 1 min 29 sec
  • test_multiprocessing_forkserver: 1 min 11 sec
  • test_multiprocessing_fork: 1 min 3 sec
  • test_asyncio: 51.7 sec
  • test_signal: 46.7 sec
  • test_socket: 37.9 sec
  • test_io: 37.1 sec
  • test_pydoc: 31.3 sec
  • test_subprocess: 30.1 sec

3 tests failed:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

13 tests skipped:
test_devpoll test_gdb test_ioctl test_kqueue test_msilib
test_startfile test_tix test_tk test_ttk_guionly test_winconsoleio
test_winreg test_winsound test_zipfile64

3 re-run tests:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

Total duration: 2 min 50 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_9d15129e'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/test/_test_multiprocessing.py", line 3774, in test_shared_memory_basics
    sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512)
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/shared_memory.py", line 103, in __init__
    self._fd = _posixshmem.shm_open(
FileExistsError: [Errno 17] File exists: '/test01_tsmb'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_1b45e0bb'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto-pgo/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_0e694706'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable LTO 3.9 has failed when building commit 94d19f6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/426/builds/219) and take a look at the build logs.
  4. Check if the failure is related to this commit (94d19f6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/426/builds/219

Failed tests:

  • test_multiprocessing_spawn
  • test_multiprocessing_forkserver
  • test_multiprocessing_fork

Failed subtests:

  • test_shared_memory_basics - test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_spawn.WithProcessesTestSharedMemory
  • test_shared_memory_basics - test.test_multiprocessing_fork.WithProcessesTestSharedMemory

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

410 tests OK.

10 slowest tests:

  • test_peg_generator: 2 min 55 sec
  • test_concurrent_futures: 2 min 48 sec
  • test_gdb: 1 min 40 sec
  • test_multiprocessing_spawn: 1 min 40 sec
  • test_multiprocessing_forkserver: 1 min 19 sec
  • test_multiprocessing_fork: 1 min 3 sec
  • test_asyncio: 55.2 sec
  • test_signal: 47.1 sec
  • test_socket: 38.5 sec
  • test_io: 35.6 sec

3 tests failed:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

12 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_startfile
test_tix test_tk test_ttk_guionly test_winconsoleio test_winreg
test_winsound test_zipfile64

3 re-run tests:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn

Total duration: 4 min 48 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_d97c27a3'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto/build/Lib/test/_test_multiprocessing.py", line 3774, in test_shared_memory_basics
    sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512)
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto/build/Lib/multiprocessing/shared_memory.py", line 103, in __init__
    self._fd = _posixshmem.shm_open(
FileExistsError: [Errno 17] File exists: '/test01_tsmb'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_ccd22972'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.9.cstratak-fedora-stable-x86_64.lto/build/Lib/multiprocessing/resource_tracker.py", line 201, in main
    cache[rtype].remove(name)
KeyError: '/psm_0c07b35b'

hrnciar added a commit to fedora-python/cpython that referenced this pull request Nov 19, 2021
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Sep 19, 2023
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Oct 2, 2023
hrnciar added a commit to fedora-python/cpython that referenced this pull request Oct 3, 2023
befeleme pushed a commit to fedora-python/cpython that referenced this pull request Oct 13, 2023
befeleme pushed a commit to fedora-python/cpython that referenced this pull request Nov 24, 2023
hrnciar added a commit to fedora-python/cpython that referenced this pull request Dec 5, 2023
hrnciar added a commit to fedora-python/cpython that referenced this pull request Dec 8, 2023
befeleme pushed a commit to fedora-python/cpython that referenced this pull request Jan 18, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Feb 7, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Feb 7, 2024
befeleme pushed a commit to fedora-python/cpython that referenced this pull request Feb 16, 2024
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Mar 13, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Mar 20, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Mar 20, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Apr 9, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Apr 10, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Jun 7, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Aug 7, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Sep 9, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Sep 9, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Sep 9, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Sep 9, 2024
hrnciar added a commit to fedora-python/cpython that referenced this pull request Oct 1, 2024
frenzymadness pushed a commit to fedora-python/cpython that referenced this pull request Dec 3, 2024
frenzymadness pushed a commit to fedora-python/cpython that referenced this pull request Dec 3, 2024
frenzymadness pushed a commit to fedora-python/cpython that referenced this pull request Dec 3, 2024
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Dec 4, 2024
stratakis pushed a commit to stratakis/cpython that referenced this pull request Dec 4, 2024
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants