from time import sleep, time from sentry_sdk._queue import Queue, FullError from sentry_sdk.utils import logger from sentry_sdk.consts import DEFAULT_QUEUE_SIZE
from typing import TYPE_CHECKING
if TYPE_CHECKING: from typing import Any from typing import Optional from typing import Callable
def start(self): # type: () -> None with self._lock: ifnot self.is_alive:
self._thread = threading.Thread(
target=self._target, name="sentry-sdk.BackgroundWorker"
)
self._thread.daemon = True try:
self._thread.start()
self._thread_for_pid = os.getpid() except RuntimeError: # At this point we can no longer start because the interpreter # is already shutting down. Sadly at this point we can no longer # send out events.
self._thread = None
def kill(self): # type: () -> None """
Kill worker thread. Returns immediately. Not useful for
waiting on shutdown for events, use `flush` for that. """
logger.debug("background worker got kill request") with self._lock: if self._thread: try:
self._queue.put_nowait(_TERMINATOR) except FullError:
logger.debug("background worker queue full, kill failed")
self._thread = None
self._thread_for_pid = None
def flush(self, timeout, callback=None): # type: (float, Optional[Any]) -> None
logger.debug("background worker got flush request") with self._lock: if self.is_alive and timeout > 0.0:
self._wait_flush(timeout, callback)
logger.debug("background worker flushed")
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.