Skip to content

Commit d9f7383

Browse files
committed
ref(worker): Change to sync flush method that launches task
GH-4581
1 parent ee44621 commit d9f7383

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sentry_sdk/worker.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,10 @@ async def _wait_flush(self, timeout: float, callback: Optional[Any] = None) -> N
271271
pending = self._queue.qsize() + len(self._active_tasks)
272272
logger.error("flush timed out, dropped %s events", pending)
273273

274-
async def flush_async(self, timeout: float, callback: Optional[Any] = None) -> None:
275-
logger.debug("background worker got flush request")
276-
if self.is_alive and timeout > 0.0:
277-
await self._wait_flush(timeout, callback)
278-
logger.debug("background worker flushed")
274+
def flush(self, timeout: float, callback: Optional[Any] = None) -> Optional[asyncio.Task[None]]: # type: ignore[override]
275+
if self.is_alive and timeout > 0.0 and self._loop and self._loop.is_running():
276+
return self._loop.create_task(self._wait_flush(timeout, callback))
277+
return None
279278

280279
def submit(self, callback: Callable[[], Any]) -> bool:
281280
self._ensure_task()

0 commit comments

Comments
 (0)