Skip to content

fix(asyncio): Remove shutdown handler #4237

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

Merged
merged 1 commit into from
Apr 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions sentry_sdk/integrations/asyncio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import signal

import sentry_sdk
from sentry_sdk.consts import OP
Expand Down Expand Up @@ -37,22 +36,6 @@ def patch_asyncio():
loop = asyncio.get_running_loop()
orig_task_factory = loop.get_task_factory()

# Add a shutdown handler to log a helpful message
def shutdown_handler():
# type: () -> None
logger.info(
"AsyncIO is shutting down. If you see 'Task was destroyed but it is pending!' "
"errors with '_task_with_sentry_span_creation', these are normal during shutdown "
"and not a problem with your code or Sentry."
)

try:
loop.add_signal_handler(signal.SIGINT, shutdown_handler)
loop.add_signal_handler(signal.SIGTERM, shutdown_handler)
except (NotImplementedError, AttributeError):
# Signal handlers might not be supported on all platforms
pass

def _sentry_task_factory(loop, coro, **kwargs):
# type: (asyncio.AbstractEventLoop, Coroutine[Any, Any, Any], Any) -> asyncio.Future[Any]

Expand Down
Loading