Skip to content

Commit 51dccfc

Browse files
committed
fix: Enforce max queue length in transport
1 parent 9a42f95 commit 51dccfc

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

sentry_sdk/worker.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BackgroundWorker(object):
2222
def __init__(self):
2323
# type: () -> None
2424
check_thread_support()
25-
self._queue = queue.Queue(-1) # type: Queue[Any]
25+
self._queue = queue.Queue(30) # type: Queue[Any]
2626
self._lock = Lock()
2727
self._thread = None # type: Optional[Thread]
2828
self._thread_for_pid = None # type: Optional[int]
@@ -89,7 +89,7 @@ def kill(self):
8989
logger.debug("background worker got kill request")
9090
with self._lock:
9191
if self._thread:
92-
self._queue.put_nowait(_TERMINATOR)
92+
self._queue.put(_TERMINATOR)
9393
self._thread = None
9494
self._thread_for_pid = None
9595

@@ -114,7 +114,10 @@ def _wait_flush(self, timeout, callback):
114114
def submit(self, callback):
115115
# type: (Callable[[], None]) -> None
116116
self._ensure_thread()
117-
self._queue.put_nowait(callback)
117+
try:
118+
self._queue.put_nowait(callback)
119+
except queue.Full:
120+
logger.debug("background worker queue full, dropping event")
118121

119122
def _target(self):
120123
# type: () -> None

0 commit comments

Comments
 (0)