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
7 changes: 4 additions & 3 deletions stompman/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio
from collections.abc import AsyncGenerator, Callable, Coroutine
from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine
from contextlib import AsyncExitStack, asynccontextmanager
from dataclasses import dataclass, field
from functools import partial
import inspect
from ssl import SSLContext
from types import TracebackType
from typing import ClassVar, Literal, Self
Expand Down Expand Up @@ -144,15 +145,15 @@ async def subscribe(
ack: AckMode = "client-individual",
headers: dict[str, str] | None = None,
on_suppressed_exception: Callable[[Exception, MessageFrame], None],
supressed_exception_classes: tuple[type[Exception], ...] = (Exception,),
suppressed_exception_classes: tuple[type[Exception], ...] = (Exception,),
) -> "Subscription":
subscription = Subscription(
destination=destination,
handler=handler,
headers=headers,
ack=ack,
on_suppressed_exception=on_suppressed_exception,
supressed_exception_classes=supressed_exception_classes,
suppressed_exception_classes=suppressed_exception_classes,
_connection_manager=self._connection_manager,
_active_subscriptions=self._active_subscriptions,
)
Expand Down
2 changes: 1 addition & 1 deletion stompman/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def write_frame(self, frame: AnyClientFrame) -> None:
async def _read_non_empty_bytes(self, max_chunk_size: int) -> bytes:
while ( # noqa: ASYNC110
chunk := await self.reader.read(max_chunk_size)
) == b"": # pragma: no cover (it defenitely happens)
) == b"": # pragma: no cover (it definitely happens)
await asyncio.sleep(0)
return chunk

Expand Down
4 changes: 2 additions & 2 deletions stompman/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Subscription:
handler: Callable[[MessageFrame], Coroutine[None, None, None]]
ack: AckMode
on_suppressed_exception: Callable[[Exception, MessageFrame], None]
supressed_exception_classes: tuple[type[Exception], ...]
suppressed_exception_classes: tuple[type[Exception], ...]
_connection_manager: ConnectionManager
_active_subscriptions: ActiveSubscriptions

Expand All @@ -48,7 +48,7 @@ async def unsubscribe(self) -> None:
async def _run_handler(self, *, frame: MessageFrame) -> None:
try:
await self.handler(frame)
except self.supressed_exception_classes as exception:
except self.suppressed_exception_classes as exception:
if self._should_handle_ack_nack and self.id in self._active_subscriptions:
await self._connection_manager.maybe_write_frame(
NackFrame(
Expand Down
4 changes: 2 additions & 2 deletions stompman/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ async def __aexit__(
await self._connection_manager.maybe_write_frame(AbortFrame(headers={"transaction": self.id}))
self._active_transactions.remove(self)
else:
commited = await self._connection_manager.maybe_write_frame(CommitFrame(headers={"transaction": self.id}))
if commited:
committed = await self._connection_manager.maybe_write_frame(CommitFrame(headers={"transaction": self.id}))
if committed:
self._active_transactions.remove(self)

async def send(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@


@pytest.mark.parametrize("ack", get_args(AckMode))
async def test_client_subscribtions_lifespan_resubscribe(ack: AckMode, faker: faker.Faker) -> None:
async def test_client_subscriptions_lifespan_resubscribe(ack: AckMode, faker: faker.Faker) -> None:
connection_class, collected_frames = create_spying_connection(*get_read_frames_with_lifespan([CONNECTED_FRAME], []))
client = EnrichedClient(connection_class=connection_class)
sub_destination, message_destination, message_body = faker.pystr(), faker.pystr(), faker.binary(length=10)
Expand Down Expand Up @@ -78,7 +78,7 @@ async def test_client_subscribtions_lifespan_resubscribe(ack: AckMode, faker: fa
)


async def test_client_subscribtions_lifespan_no_active_subs_in_aexit(
async def test_client_subscriptions_lifespan_no_active_subs_in_aexit(
monkeypatch: pytest.MonkeyPatch, faker: faker.Faker
) -> None:
monkeypatch.setattr(
Expand Down Expand Up @@ -109,7 +109,7 @@ async def test_client_subscribtions_lifespan_no_active_subs_in_aexit(


@pytest.mark.parametrize("direct_error", [True, False])
async def test_client_subscribtions_lifespan_with_active_subs_in_aexit(
async def test_client_subscriptions_lifespan_with_active_subs_in_aexit(
monkeypatch: pytest.MonkeyPatch,
faker: faker.Faker,
*,
Expand Down