Skip to content

Commit

Permalink
fix: warnings with aio-pika>=9.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bmario committed Dec 3, 2024
1 parent 1f16fdc commit 72ee749
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
10 changes: 6 additions & 4 deletions metricq/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,14 @@ async def _on_management_message(
if r is not None:
await r

def _on_reconnect(self, sender: aio_pika.abc.AbstractRobustConnection) -> None:
def _on_reconnect(
self, sender: Optional[aio_pika.abc.AbstractRobustConnection]
) -> None:
logger.info("Reconnected to {}", sender)

def _on_close(
self,
sender: aio_pika.abc.AbstractRobustConnection,
sender: Optional[aio_pika.abc.AbstractConnection],
exception: Optional[BaseException],
) -> None:
if isinstance(exception, asyncio.CancelledError):
Expand All @@ -816,13 +818,13 @@ def _on_close(
)

def _on_management_connection_reconnect(
self, sender: aio_pika.abc.AbstractRobustConnection
self, sender: Optional[aio_pika.abc.AbstractRobustConnection]
) -> None:
self._management_connection_watchdog.set_established()

def _on_management_connection_close(
self,
sender: aio_pika.abc.AbstractRobustConnection,
sender: Optional[aio_pika.abc.AbstractConnection],
_exception: Optional[BaseException],
) -> None:
self._management_connection_watchdog.set_closed()
4 changes: 2 additions & 2 deletions metricq/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ async def teardown(self) -> None:

def _on_data_connection_close(
self,
sender: aio_pika.abc.AbstractRobustConnection,
sender: Optional[aio_pika.abc.AbstractConnection],
_exception: Optional[BaseException],
) -> None:
self._data_connection_watchdog.set_closed()

def _on_data_connection_reconnect(
self, sender: aio_pika.abc.AbstractRobustConnection
self, sender: Optional[aio_pika.abc.AbstractConnection]
) -> None:
self._data_connection_watchdog.set_established()
6 changes: 4 additions & 2 deletions metricq/history_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,13 @@ async def _on_history_response(

def _on_history_connection_close(
self,
sender: aio_pika.abc.AbstractRobustConnection,
sender: Optional[aio_pika.abc.AbstractConnection],
_exception: Optional[BaseException],
) -> None:
self._history_connection_watchdog.set_closed()

def _on_history_connection_reconnect(
self, sender: aio_pika.abc.AbstractRobustConnection
self, sender: Optional[aio_pika.abc.AbstractConnection]
) -> None:
logger.info("History connection ({}) reestablished!", sender)

Expand All @@ -764,6 +764,8 @@ def _on_history_connection_reconnect(
)
self._reregister_task.cancel()

assert sender is not None

self._reregister_task = self._event_loop.create_task(self._reregister(sender))

def reregister_done(task: Task[None]) -> None:
Expand Down
4 changes: 3 additions & 1 deletion metricq/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def sink_config(self, dataQueue: str, **kwargs: Any) -> None:
self._data_consumer_tag = await self._data_queue.consume(self._on_data_message)

def _on_data_connection_reconnect(
self, sender: aio_pika.abc.AbstractConnection
self, sender: Optional[aio_pika.abc.AbstractConnection]
) -> None:
logger.info("Sink data connection ({}) reestablished!", sender)

Expand All @@ -87,6 +87,8 @@ def _on_data_connection_reconnect(
)
self._resubscribe_task.cancel()

assert sender is not None

self._resubscribe_task = self._event_loop.create_task(self._resubscribe(sender))

def resubscribe_done(task: Task[None]) -> None:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from bisect import bisect_right
from datetime import datetime
from distutils.errors import DistutilsFileError
from distutils.log import ERROR, INFO
from distutils.log import ERROR, INFO # type: ignore
from distutils.spawn import find_executable
from operator import itemgetter
from typing import Any, Iterable, Optional
Expand Down Expand Up @@ -134,7 +134,7 @@ def make_protobuf_requirement(major: int, minor: int, patch: int) -> str:
py_major = protobuf_version_mapping[
bisect_right(protobuf_version_mapping, minor, key=itemgetter(1)) - 1
][0]
return f"protobuf>={py_major}.{minor}, <{py_major}.{minor+1}"
return f"protobuf>={py_major}.{minor}, <{py_major}.{minor + 1}"


def get_protobuf_requirement_from_protoc() -> str:
Expand Down

0 comments on commit 72ee749

Please sign in to comment.