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

Python 3.12: can't create new thread at interpreter shutdown #2027

Open
robhudson opened this issue Apr 4, 2024 · 0 comments
Open

Python 3.12: can't create new thread at interpreter shutdown #2027

robhudson opened this issue Apr 4, 2024 · 0 comments

Comments

@robhudson
Copy link

  • gevent version: 24.2.1 from pypi
  • Python version: cPython 3.12.2 via python:3.12-slim-bookworm Docker
  • Operating System: Ubuntu via python:3.12-slim-bookworm Docker

Description:

Running gunicorn + gevent, received reports via Sentry:

RuntimeError: can't create new thread at interpreter shutdown
  File "newrelic/core/application.py", line 1346, in harvest
    self._active_session.send_span_events(spans.sampling_info, span_samples)
  File "newrelic/core/data_collector.py", line 133, in send_span_events
    return self._protocol.send("span_event_data", payload)
  File "newrelic/core/agent_protocol.py", line 230, in send
    response = self.client.send_request(path=path, params=params, headers=headers, payload=payload)
  File "newrelic/common/agent_http.py", line 446, in send_request
    response = self._connection.request_encode_url(
  File "newrelic/packages/urllib3/request.py", line 96, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "newrelic/packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "newrelic/packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "newrelic/packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "newrelic/packages/urllib3/connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
  File "newrelic/packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "newrelic/packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "gevent/_socketcommon.py", line 225, in getaddrinfo
    addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
  File "gevent/resolver/thread.py", line 63, in getaddrinfo
    return self.pool.apply(_socket.getaddrinfo, args, kwargs)
  File "gevent/pool.py", line 161, in apply
    return self.spawn(func, *args, **kwds).get()
  File "gevent/threadpool.py", line 546, in spawn
    self.adjust()
  File "gevent/threadpool.py", line 492, in adjust
    self._adjust_step()
  File "gevent/threadpool.py", line 472, in _adjust_step
    self._add_thread()
  File "gevent/threadpool.py", line 499, in _add_thread
    self._WorkerGreenlet(self)
  File "gevent/threadpool.py", line 106, in __init__
    start_new_thread(self._begin, ())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant