Skip to content

Commit d2e647b

Browse files
committed
ref(worker): Readd coroutine check for worker callbacks
The flush method in the transport enqueues a sync callback for the worker, therefore the check needs to be here after all. GH-4581
1 parent d9f7383 commit d2e647b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sentry_sdk/worker.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import threading
55
import asyncio
6+
import inspect
67

78
from time import sleep, time
89
from sentry_sdk._queue import Queue, FullError
@@ -305,7 +306,11 @@ async def _target(self) -> None:
305306

306307
async def _process_callback(self, callback: Callable[[], Any]) -> None:
307308
# Callback is an async coroutine, need to await it
308-
await callback()
309+
if inspect.iscoroutinefunction(callback):
310+
await callback()
311+
else:
312+
# Callback is a sync function, such as _flush_client_reports()
313+
callback()
309314

310315
def _on_task_complete(self, task: asyncio.Task[None]) -> None:
311316
try:

0 commit comments

Comments
 (0)