Repository: getsentry/sentry-python

Issue:
There is error when connection is lost between client and server
I have the same problem.  If set invalid DSN, sentry client tries to send one event while shutdown timeout does not end.

```python
import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration

DSN = 'https://xxx@mysite.com/123'

sentry_sdk.init(
    dsn=DSN,
    integrations=[LoggingIntegration(
        level=logging.INFO,
        event_level=logging.INFO
    )],
    shutdown_timeout=5,
    debug=True
)

logging.error('some error')
```

Execute `python cli.py 2>&1 | tee log`

```
 [sentry] DEBUG: Setting up integrations (with default = True)
 [sentry] DEBUG: Setting up previously not enabled integration logging
 [sentry] DEBUG: Setting up previously not enabled integration stdlib
 [sentry] DEBUG: Setting up previously not enabled integration excepthook
 [sentry] DEBUG: Setting up previously not enabled integration dedupe
 [sentry] DEBUG: Setting up previously not enabled integration atexit
 [sentry] DEBUG: Setting up previously not enabled integration modules
 [sentry] DEBUG: Setting up previously not enabled integration argv
 [sentry] DEBUG: Setting up previously not enabled integration threading
 [sentry] DEBUG: Enabling integration logging
 [sentry] DEBUG: Enabling integration stdlib
 [sentry] DEBUG: Enabling integration excepthook
 [sentry] DEBUG: Enabling integration dedupe
 [sentry] DEBUG: Enabling integration atexit
 [sentry] DEBUG: Enabling integration modules
 [sentry] DEBUG: Enabling integration argv
 [sentry] DEBUG: Enabling integration threading
ERROR:root:some error
 [sentry] DEBUG: atexit: got shutdown signal
DEBUG:sentry_sdk.errors:atexit: got shutdown signal
 [sentry] DEBUG: Sending event, type:null level:error event_id:45c1a32d722d49558f6b0259cb63a129 project:123 host:mysite.com
DEBUG:sentry_sdk.errors:Sending event, type:null level:error event_id:45c1a32d722d49558f6b0259cb63a129 project:123 host:mysite.com
 [sentry] DEBUG: atexit: shutting down client
DEBUG:sentry_sdk.errors:atexit: shutting down client
 [sentry] DEBUG: Flushing HTTP transport
DEBUG:sentry_sdk.errors:Flushing HTTP transport
 [sentry] DEBUG: background worker got flush request
DEBUG:sentry_sdk.errors:background worker got flush request
 [sentry] DEBUG: 0 event(s) pending on flush
DEBUG:sentry_sdk.errors:0 event(s) pending on flush
Sentry is attempting to send 0 pending error messages
Waiting up to 5 seconds
Press Ctrl-C to quit
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7e2a8f10>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c3a73d0>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c3a7a10>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
 [sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7cedc2d0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7cedc2d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
ERROR:sentry_sdk.errors:Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7cedc2d0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7cedc2d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
 [sentry] DEBUG: Sending event, type:null level:warning event_id:0c03c8eac9e94cf7a81b1010b43a2568 project:123 host:mysite.com
DEBUG:sentry_sdk.errors:Sending event, type:null level:warning event_id:0c03c8eac9e94cf7a81b1010b43a2568 project:123 host:mysite.com
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7cc017d0>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15d090>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15d6d0>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
 [sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15dd10>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15dd10>: Failed to establish a new connection: [Errno 111] Connection refused'))
ERROR:sentry_sdk.errors:Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15dd10>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15dd10>: Failed to establish a new connection: [Errno 111] Connection refused'))
 [sentry] DEBUG: Sending event, type:null level:warning event_id:7a1e295e227c4e498ed69390b90979d4 project:123 host:mysite.com
DEBUG:sentry_sdk.errors:Sending event, type:null level:warning event_id:7a1e295e227c4e498ed69390b90979d4 project:123 host:mysite.com
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15d150>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c16b550>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c16bc50>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
 [sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c176350>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c176350>: Failed to establish a new connection: [Errno 111] Connection refused'))
ERROR:sentry_sdk.errors:Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c176350>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c176350>: Failed to establish a new connection: [Errno 111] Connection refused'))
 [sentry] DEBUG: Sending event, type:null level:warning event_id:1cca83a5f860481e8a43119342b2e14b project:123 host:mysite.com
DEBUG:sentry_sdk.errors:Sending event, type:null level:warning event_id:1cca83a5f860481e8a43119342b2e14b project:123 host:mysite.com
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c176510>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15d150>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15d350>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
 [sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c155ed0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c155ed0>: Failed to establish a new connection: [Errno 111] Connection refused'))
ERROR:sentry_sdk.errors:Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c155ed0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c155ed0>: Failed to establish a new connection: [Errno 111] Connection refused'))
 [sentry] DEBUG: Sending event, type:null level:warning event_id:f046af0775f8455aa45b0e88e2a73d71 project:123 host:mysite.com
DEBUG:sentry_sdk.errors:Sending event, type:null level:warning event_id:f046af0775f8455aa45b0e88e2a73d71 project:123 host:mysite.com
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7cc017d0>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c176350>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c15d450>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/123/store/
 [sentry] ERROR: Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c16b910>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c16b910>: Failed to establish a new connection: [Errno 111] Connection refused'))
ERROR:sentry_sdk.errors:Internal error in sentry_sdk
Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c16b910>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 296, in send_event_wrapper
    self._send_event(event)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 217, in _send_event
    headers={"Content-Type": "application/json", "Content-Encoding": "gzip"},
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/sentry_sdk/transport.py", line 164, in _send_request
    "POST", str(self._auth.store_api_url), body=body, headers=headers
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 760, in urlopen
    **response_kw
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/tmp/sentry/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mysite.com', port=443): Max retries exceeded with url: /api/123/store/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c7c16b910>: Failed to establish a new connection: [Errno 111] Connection refused'))
 [sentry] DEBUG: Sending event, type:null level:warning event_id:1a3e309ec6ab48e69f97306f6ea632dd project:123 host:mysite.com
DEBUG:sentry_sdk.errors:Sending event, type:null level:warning event_id:1a3e309ec6ab48e69f97306f6ea632dd project:123 host:mysite.com
 [sentry] DEBUG: background worker flushed
DEBUG:sentry_sdk.errors:background worker flushed
 [sentry] DEBUG: Killing HTTP transport
DEBUG:sentry_sdk.errors:Killing HTTP transport
 [sentry] DEBUG: background worker got kill request
DEBUG:sentry_sdk.errors:background worker got kill request
```

- python3.7
- sentry-sdk==0.14.3
- urllib3==1.25.8

_Originally posted by @ansizov in https://github.com/getsentry/sentry-python/issues/399#issuecomment-602259010_


Discussion:
I have detected problem:

1. Application raises some error.
2. SDK tries to send event and uses urllib3.
3. urllib3 cannot send data and urllib3.connectionpool.py:745 writes log.
```
log.warning(
    "Retrying (%r) after connection broken by '%r': %s", retries, err, url
)
```
4. Python logger handles this warning and calls `sentry_sdk/integrations/logging.py` `sentry_patched_callhandlers`.
5. `_IGNORED_LOGGERS = set(["sentry_sdk.errors"])` but current `record.name = urllib3.connectionpool`.
6. goto item 3.

Worker's queue is growing.

Resolving patch:
diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py
--- a/sentry_sdk/integrations/logging.py
+++ b/sentry_sdk/integrations/logging.py
@@ -24,7 +24,13 @@
 DEFAULT_LEVEL = logging.INFO
 DEFAULT_EVENT_LEVEL = logging.ERROR
 
-_IGNORED_LOGGERS = set(["sentry_sdk.errors"])
+# Capturing events from those loggers causes recursion errors. We cannot allow
+# the user to unconditionally create events from those loggers under any
+# circumstances.
+#
+# Note: Ignoring by logger name here is better than mucking with thread-locals.
+# We do not necessarily know whether thread-locals work 100% correctly in the user's environment.
+_IGNORED_LOGGERS = set(["sentry_sdk.errors", "urllib3.connectionpool"])
 
 
 def ignore_logger(


Test patch:
diff --git a/tests/test_transport.py b/tests/test_transport.py
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -8,6 +8,7 @@
 
 from sentry_sdk import Hub, Client, add_breadcrumb, capture_message
 from sentry_sdk.transport import _parse_rate_limits
+from sentry_sdk.integrations.logging import LoggingIntegration
 
 
 @pytest.fixture(params=[True, False])
@@ -57,6 +58,23 @@ def test_transport_works(
     assert any("Sending event" in record.msg for record in caplog.records) == debug
 
 
+def test_transport_infinite_loop(httpserver, request):
+    httpserver.serve_content("ok", 200)
+
+    client = Client(
+        "http://foobar@{}/123".format(httpserver.url[len("http://") :]),
+        debug=True,
+        # Make sure we cannot create events from our own logging
+        integrations=[LoggingIntegration(event_level=logging.DEBUG)],
+    )
+
+    with Hub(client):
+        capture_message("hi")
+        client.flush()
+
+    assert len(httpserver.requests) == 1
+
+
 NOW = datetime(2014, 6, 2)