open-telemetry / open-telemetry/opentelemetry-python

RuntimeError: can't create new thread at interpreter shutdown

Open
#4,752 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Describe your environment

OS: Ubuntu
Python version: 3.12.0, 3.12.1, 3.12.2
SDK version: Since 1.36.0
API version: Since 1.36.0

What happened?
Exception ignored in atexit callback: <function shutdown at 0x72be9c2a93a0>
Traceback (most recent call last):
  File "/home/codespace/.python/current/lib/python3.12/logging/__init__.py", line 2271, in shutdown
    h.flush()
  File "/workspaces/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py", line 654, in flush
    thread.start()
  File "/home/codespace/.python/current/lib/python3.12/threading.py", line 992, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't create new thread at interpreter shutdown
Steps to Reproduce
  1. Run the example here with python 3.12.0
Expected Result

No RuntimeError

Actual Result

RuntimeError

Additional context

Got this after this PR

Probably due to: https://github.com/python/cpython/issues/113964

Would you like to implement a fix?

None

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run docs/examples/logs/example.py with Python 3.12 and reproduce the shutdown traceback. Start at opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/init.py around flush(), then compare the behavior with the linked CPython issue; done means the example exits without the RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.