Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion linter-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ types-certifi
types-redis
types-setuptools
flake8-bugbear==21.4.3
pep8-naming==0.11.1
pep8-naming==0.13.0
pre-commit # local linting
26 changes: 13 additions & 13 deletions sentry_sdk/_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
if MYPY:
from typing import Any

__all__ = ["Empty", "Full", "Queue"]
__all__ = ["EmptyError", "FullError", "Queue"]


class Empty(Exception):
class EmptyError(Exception):
"Exception raised by Queue.get(block=0)/get_nowait()."
pass


class Full(Exception):
class FullError(Exception):
"Exception raised by Queue.put(block=0)/put_nowait()."
pass

Expand Down Expand Up @@ -134,16 +134,16 @@ def put(self, item, block=True, timeout=None):
If optional args 'block' is true and 'timeout' is None (the default),
block if necessary until a free slot is available. If 'timeout' is
a non-negative number, it blocks at most 'timeout' seconds and raises
the Full exception if no free slot was available within that time.
the FullError exception if no free slot was available within that time.
Otherwise ('block' is false), put an item on the queue if a free slot
is immediately available, else raise the Full exception ('timeout'
is immediately available, else raise the FullError exception ('timeout'
is ignored in that case).
"""
with self.not_full:
if self.maxsize > 0:
if not block:
if self._qsize() >= self.maxsize:
raise Full()
raise FullError()
elif timeout is None:
while self._qsize() >= self.maxsize:
self.not_full.wait()
Expand All @@ -154,7 +154,7 @@ def put(self, item, block=True, timeout=None):
while self._qsize() >= self.maxsize:
remaining = endtime - time()
if remaining <= 0.0:
raise Full
raise FullError()
self.not_full.wait(remaining)
self._put(item)
self.unfinished_tasks += 1
Expand All @@ -166,15 +166,15 @@ def get(self, block=True, timeout=None):
If optional args 'block' is true and 'timeout' is None (the default),
block if necessary until an item is available. If 'timeout' is
a non-negative number, it blocks at most 'timeout' seconds and raises
the Empty exception if no item was available within that time.
the EmptyError exception if no item was available within that time.
Otherwise ('block' is false), return an item if one is immediately
available, else raise the Empty exception ('timeout' is ignored
available, else raise the EmptyError exception ('timeout' is ignored
in that case).
"""
with self.not_empty:
if not block:
if not self._qsize():
raise Empty()
raise EmptyError()
elif timeout is None:
while not self._qsize():
self.not_empty.wait()
Expand All @@ -185,7 +185,7 @@ def get(self, block=True, timeout=None):
while not self._qsize():
remaining = endtime - time()
if remaining <= 0.0:
raise Empty()
raise EmptyError()
self.not_empty.wait(remaining)
item = self._get()
self.not_full.notify()
Expand All @@ -195,15 +195,15 @@ def put_nowait(self, item):
"""Put an item into the queue without blocking.

Only enqueue the item if a free slot is immediately available.
Otherwise raise the Full exception.
Otherwise raise the FullError exception.
"""
return self.put(item, block=False)

def get_nowait(self):
"""Remove and return an item from the queue without blocking.

Only get an item if one is immediately available. Otherwise
raise the Empty exception.
raise the EmptyError exception.
"""
return self.get(block=False)

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def setup_integrations(
return integrations


class DidNotEnable(Exception):
class DidNotEnable(Exception): # noqa: N818
"""
The integration could not be enabled due to a trivial user error like
`flask` not being installed for the `FlaskIntegration`.
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def transaction_from_function(func):
disable_capture_event = ContextVar("disable_capture_event")


class ServerlessTimeoutWarning(Exception):
class ServerlessTimeoutWarning(Exception): # noqa: N818
"""Raised when a serverless method is about to reach its timeout."""

pass
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from time import sleep, time
from sentry_sdk._compat import check_thread_support
from sentry_sdk._queue import Queue, Full
from sentry_sdk._queue import Queue, FullError
from sentry_sdk.utils import logger
from sentry_sdk.consts import DEFAULT_QUEUE_SIZE

Expand Down Expand Up @@ -81,7 +81,7 @@ def kill(self):
if self._thread:
try:
self._queue.put_nowait(_TERMINATOR)
except Full:
except FullError:
logger.debug("background worker queue full, kill failed")

self._thread = None
Expand Down Expand Up @@ -114,7 +114,7 @@ def submit(self, callback):
try:
self._queue.put_nowait(callback)
return True
except Full:
except FullError:
return False

def _target(self):
Expand Down
14 changes: 7 additions & 7 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
from collections.abc import Mapping


class EventCaptured(Exception):
class EventCapturedError(Exception):
pass


class _TestTransport(Transport):
def capture_event(self, event):
raise EventCaptured(event)
raise EventCapturedError(event)


def test_transport_option(monkeypatch):
Expand Down Expand Up @@ -273,7 +273,7 @@ def e(exc):

e(ZeroDivisionError())
e(MyDivisionError())
pytest.raises(EventCaptured, lambda: e(ValueError()))
pytest.raises(EventCapturedError, lambda: e(ValueError()))


def test_with_locals_enabled(sentry_init, capture_events):
Expand Down Expand Up @@ -400,8 +400,8 @@ def test_attach_stacktrace_disabled(sentry_init, capture_events):

def test_capture_event_works(sentry_init):
sentry_init(transport=_TestTransport())
pytest.raises(EventCaptured, lambda: capture_event({}))
pytest.raises(EventCaptured, lambda: capture_event({}))
pytest.raises(EventCapturedError, lambda: capture_event({}))
pytest.raises(EventCapturedError, lambda: capture_event({}))


@pytest.mark.parametrize("num_messages", [10, 20])
Expand Down Expand Up @@ -744,10 +744,10 @@ def test_errno_errors(sentry_init, capture_events):
sentry_init()
events = capture_events()

class Foo(Exception):
class FooError(Exception):
errno = 69

capture_exception(Foo())
capture_exception(FooError())

(event,) = events

Expand Down