Skip to content

Commit e1280f9

Browse files
committed
ref(worker): Amend return type of submit and flush to accomodate for coroutines
Coroutines do not return None, therefore it is necessary to consider this in the callback parameter of the worker. Previously, only callbacks with return Type None were accepted. GH-4581
1 parent d6b7633 commit e1280f9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sentry_sdk/worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def kill(self) -> None:
3636
pass
3737

3838
def flush(
39-
self, timeout: float, callback: Optional[Callable[[int, float], None]] = None
39+
self, timeout: float, callback: Optional[Callable[[int, float], Any]] = None
4040
) -> None:
4141
"""
4242
Flush the worker.
@@ -52,7 +52,7 @@ def full(self) -> bool:
5252
pass
5353

5454
@abstractmethod
55-
def submit(self, callback: Callable[[], None]) -> bool:
55+
def submit(self, callback: Callable[[], Any]) -> bool:
5656
"""
5757
Schedule a callback to be executed by the worker.
5858
@@ -151,7 +151,7 @@ def _wait_flush(self, timeout: float, callback: Optional[Any]) -> None:
151151
pending = self._queue.qsize() + 1
152152
logger.error("flush timed out, dropped %s events", pending)
153153

154-
def submit(self, callback: Callable[[], None]) -> bool:
154+
def submit(self, callback: Callable[[], Any]) -> bool:
155155
self._ensure_thread()
156156
try:
157157
self._queue.put_nowait(callback)
@@ -243,7 +243,7 @@ async def flush_async(self, timeout: float, callback: Optional[Any] = None) -> N
243243
await self._wait_flush(timeout, callback)
244244
logger.debug("background worker flushed")
245245

246-
def submit(self, callback: Callable[[], None]) -> bool:
246+
def submit(self, callback: Callable[[], Any]) -> bool:
247247
self._ensure_task()
248248

249249
try:

0 commit comments

Comments
 (0)