Skip to content

Commit ceb826b

Browse files
revert: "fix: shut down "session flusher" more promptly (#4561)"
This reverts commit 5709b25.
1 parent f4907a9 commit ceb826b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sentry_sdk/sessions.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
2+
import time
23
import warnings
3-
from threading import Thread, Lock, Event
4+
from threading import Thread, Lock
45
from contextlib import contextmanager
56

67
import sentry_sdk
@@ -161,7 +162,7 @@ def __init__(
161162
self._thread_lock = Lock()
162163
self._aggregate_lock = Lock()
163164
self._thread_for_pid = None # type: Optional[int]
164-
self.__shutdown_requested = Event()
165+
self._running = True
165166

166167
def flush(self):
167168
# type: (...) -> None
@@ -207,10 +208,10 @@ def _ensure_running(self):
207208

208209
def _thread():
209210
# type: (...) -> None
210-
running = True
211-
while running:
212-
running = not self.__shutdown_requested.wait(self.flush_interval)
213-
self.flush()
211+
while self._running:
212+
time.sleep(self.flush_interval)
213+
if self._running:
214+
self.flush()
214215

215216
thread = Thread(target=_thread)
216217
thread.daemon = True
@@ -219,7 +220,7 @@ def _thread():
219220
except RuntimeError:
220221
# Unfortunately at this point the interpreter is in a state that no
221222
# longer allows us to spawn a thread and we have to bail.
222-
self.__shutdown_requested.set()
223+
self._running = False
223224
return None
224225

225226
self._thread = thread
@@ -270,4 +271,4 @@ def add_session(
270271

271272
def kill(self):
272273
# type: (...) -> None
273-
self.__shutdown_requested.set()
274+
self._running = False

0 commit comments

Comments
 (0)