summaryrefslogtreecommitdiff
path: root/kombu/compat.py
diff options
context:
space:
mode:
Diffstat (limited to 'kombu/compat.py')
-rw-r--r--kombu/compat.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/kombu/compat.py b/kombu/compat.py
index 1fa3f631..d90aec75 100644
--- a/kombu/compat.py
+++ b/kombu/compat.py
@@ -3,11 +3,17 @@
See https://pypi.org/project/carrot/ for documentation.
"""
+from __future__ import annotations
+
from itertools import count
+from typing import TYPE_CHECKING
from . import messaging
from .entity import Exchange, Queue
+if TYPE_CHECKING:
+ from types import TracebackType
+
__all__ = ('Publisher', 'Consumer')
# XXX compat attribute
@@ -65,7 +71,12 @@ class Publisher(messaging.Producer):
def __enter__(self):
return self
- def __exit__(self, *exc_info):
+ def __exit__(
+ self,
+ exc_type: type[BaseException] | None,
+ exc_val: BaseException | None,
+ exc_tb: TracebackType | None
+ ) -> None:
self.close()
@property
@@ -127,7 +138,12 @@ class Consumer(messaging.Consumer):
def __enter__(self):
return self
- def __exit__(self, *exc_info):
+ def __exit__(
+ self,
+ exc_type: type[BaseException] | None,
+ exc_val: BaseException | None,
+ exc_tb: TracebackType | None
+ ) -> None:
self.close()
def __iter__(self):