Skip to content

Commit 2b3014e

Browse files
committed
Merge branch 'srothh/worker-class-hierarchy' into srothh/async-task-worker
Merge changes of worker/transport ABC structure
2 parents 79a1bb6 + 8539925 commit 2b3014e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

sentry_sdk/transport.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ def flush(
107107
"""
108108
return None
109109

110+
async def flush_async(
111+
self: Self,
112+
timeout: float,
113+
callback: Optional[Any] = None,
114+
) -> None:
115+
"""
116+
Send out current events within `timeout` seconds. This method needs to be awaited for blocking behavior.
117+
118+
The default implementation is a no-op, since this method may only be relevant to some transports.
119+
Subclasses should override this method if necessary.
120+
"""
121+
return None
122+
110123
def kill(self: Self) -> None:
111124
"""
112125
Forcefully kills the transport.

sentry_sdk/worker.py

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

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

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

0 commit comments

Comments
 (0)