Skip to content

Commit 0bc8562

Browse files
committed
ref(worker): Add flush_async method to Worker ABC
Add a new flush_async method to worker ABC. This is necessary because the async transport cannot use a synchronous blocking flush. GH-4578
1 parent fce4404 commit 0bc8562

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sentry_sdk/worker.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,29 @@ def is_alive(self) -> bool:
3333
def kill(self) -> None:
3434
pass
3535

36-
@abstractmethod
3736
def flush(
3837
self, timeout: float, callback: Optional[Callable[[int, float], None]] = None
3938
) -> None:
4039
"""
4140
Flush the worker.
4241
4342
This method blocks until the worker has flushed all events or the specified timeout is reached.
43+
Default implementation is a no-op, since this method may only be relevant to some workers.
44+
Subclasses should override this method if necessary.
4445
"""
45-
pass
46+
return None
47+
48+
async def flush_async(
49+
self, timeout: float, callback: Optional[Callable[[int, float], None]] = None
50+
) -> None:
51+
"""
52+
Flush the worker.
53+
54+
This method can be awaited until the worker has flushed all events or the specified timeout is reached.
55+
Default implementation is a no-op, since this method may only be relevant to some workers.
56+
Subclasses should override this method if necessary.
57+
"""
58+
return None
4659

4760
@abstractmethod
4861
def full(self) -> bool:

0 commit comments

Comments
 (0)