amqp-client-python 0.2.0.post1__py3-none-any.whl → 0.2.1.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,3 +2,14 @@ from .rabbitmq import EventbusRabbitMQ, AsyncEventbusRabbitMQ, EventbusWrapperRa
2
2
  from .domain.models import Config, Options, SSLOptions
3
3
  from .domain.utils import ConnectionType
4
4
  from pika import DeliveryMode
5
+
6
+ __all__ = [
7
+ "EventbusRabbitMQ",
8
+ "AsyncEventbusRabbitMQ",
9
+ "EventbusWrapperRabbitMQ",
10
+ "Config",
11
+ "Options",
12
+ "SSLOptions",
13
+ "ConnectionType",
14
+ "DeliveryMode",
15
+ ]
@@ -1,3 +1,9 @@
1
1
  from .config import Config
2
2
  from .options import Options
3
3
  from .ssl_options import SSLOptions
4
+
5
+ __all__ = [
6
+ "Config",
7
+ "Options",
8
+ "SSLOptions",
9
+ ]
@@ -1,2 +1,7 @@
1
1
  from .connection_type import ConnectionType
2
2
  from .types import HandlerType
3
+
4
+ __all__ = [
5
+ "ConnectionType",
6
+ "HandlerType",
7
+ ]
@@ -4,3 +4,12 @@ from .async_provider_handler import AsyncProviderHandler
4
4
  from .async_subscriber_handler import AsyncSubscriberHandler
5
5
  from .provider_handler import ProviderHandler
6
6
  from .subscriber_handler import SubscriberHandler
7
+
8
+ __all__ = [
9
+ "IntegrationEvent",
10
+ "IntegrationEventHandler",
11
+ "AsyncProviderHandler",
12
+ "AsyncSubscriberHandler",
13
+ "ProviderHandler",
14
+ "SubscriberHandler",
15
+ ]
@@ -7,3 +7,15 @@ from .publish_timeout_exception import PublishTimeoutException
7
7
  from .auto_reconnect_exception import AutoReconnectException
8
8
  from .blocking_exception import BlockingException
9
9
  from .thread_unsafe_exception import ThreadUnsafeException
10
+
11
+ __all__ = [
12
+ "EventBusException",
13
+ "NackException",
14
+ "RpcProviderException",
15
+ "TimeoutException",
16
+ "ResponseTimeoutException",
17
+ "PublishTimeoutException",
18
+ "AutoReconnectException",
19
+ "BlockingException",
20
+ "ThreadUnsafeException",
21
+ ]
@@ -1,6 +1,6 @@
1
1
  from .async_eventbus_rabbitmq import AsyncEventbusRabbitMQ
2
2
  from .async_connection_factory import AsyncConnectionFactoryRabbitMQ
3
- from .async_connection import AsyncConnection, ConnectionType
3
+ from .async_connection import AsyncConnection
4
4
  from .async_channel_factory import AsyncChannelFactoryRabbitMQ
5
5
  from .async_channel import AsyncChannel
6
6
  from .eventbus_rabbitmq import EventbusRabbitMQ
@@ -9,3 +9,17 @@ from .connection_rabbitmq import ConnectionRabbitMQ
9
9
  from .channel_factory_rabbitmq import ChannelFactoryRabbitMQ
10
10
  from .channel_rabbitmq import ChannelRabbitMQ
11
11
  from .eventbus_wrapper_rabbitmq import EventbusWrapperRabbitMQ
12
+
13
+ __all__ = [
14
+ "AsyncEventbusRabbitMQ",
15
+ "AsyncConnectionFactoryRabbitMQ",
16
+ "AsyncConnection",
17
+ "AsyncChannelFactoryRabbitMQ",
18
+ "AsyncChannel",
19
+ "EventbusRabbitMQ",
20
+ "ConnectionFactoryRabbitMQ",
21
+ "ConnectionRabbitMQ",
22
+ "ChannelFactoryRabbitMQ",
23
+ "ChannelRabbitMQ",
24
+ "EventbusWrapperRabbitMQ",
25
+ ]
@@ -1,3 +1,4 @@
1
+ from collections import deque
1
2
  from typing import MutableMapping, Mapping, Optional, Union, Dict, List
2
3
  from .async_channel_factory import AsyncChannelFactoryRabbitMQ
3
4
  from amqp_client_python.exceptions import (
@@ -63,9 +64,9 @@ class AsyncChannel:
63
64
  def is_open(self) -> Optional[bool]:
64
65
  return self._channel and self._channel.is_open
65
66
 
66
- def open(self, connection: AsyncioConnection, callbacks=[]):
67
+ def open(self, connection: AsyncioConnection, callbacks=None):
67
68
  if not self.is_open:
68
- self.callbacks = callbacks
69
+ self.callbacks = callbacks if callbacks is not None else deque()
69
70
  self._connection = connection
70
71
  self.ioloop = connection.ioloop
71
72
  self._channel = self.channel_factory.create_channel(
@@ -87,10 +88,15 @@ class AsyncChannel:
87
88
  self.ioloop.create_task(self.process_callbacks()) # type: ignore
88
89
 
89
90
  async def process_callbacks(self):
90
- for callback, future in self.callbacks:
91
- result = await callback()
92
- if not future.done():
93
- future.set_result(result)
91
+ while self.callbacks:
92
+ callback, future = self.callbacks.popleft()
93
+ try:
94
+ result = await callback()
95
+ if not future.done():
96
+ future.set_result(result)
97
+ except Exception as exc:
98
+ if not future.done():
99
+ future.set_exception(exc)
94
100
 
95
101
  def add_on_channel_close_callback(self):
96
102
  """This method tells pika to call the on_channel_closed method if
@@ -302,7 +308,7 @@ class AsyncChannel:
302
308
  if self.rpc_publisher_started:
303
309
  return True
304
310
  if self.rpc_publisher_starting:
305
- return await self.rpc_consumer_future
311
+ return await self.rpc_publisher_future
306
312
  self.rpc_publisher_starting = True
307
313
  self.rpc_publisher_future = self.ioloop.create_future()
308
314
 
@@ -1,4 +1,6 @@
1
- from typing import Optional, Callable, Awaitable, Tuple, Dict, List, Any
1
+ from collections import deque
2
+ from typing import Optional, Callable, Awaitable, Tuple, Dict, Any
3
+
2
4
  from .async_connection_factory import AsyncConnectionFactoryRabbitMQ, AsyncioConnection
3
5
  from .async_channel import AsyncChannel
4
6
  from ..exceptions import AutoReconnectException
@@ -60,7 +62,7 @@ class AsyncConnection:
60
62
  self.openning = False
61
63
  self.reconnecting = False
62
64
  self.reconnect_delay = 1
63
- self.callbacks: List[Tuple[Callable, Future]] = []
65
+ self.callbacks: deque[Tuple[Callable, Future]] = deque()
64
66
  self.type = connection_type
65
67
  self.backup: Dict[str, Dict[str, Any]] = {
66
68
  "exchange": {},
@@ -87,6 +89,7 @@ class AsyncConnection:
87
89
  if not self.ioloop:
88
90
  self.ioloop = get_event_loop()
89
91
  self.openning = True
92
+ self._closing = False
90
93
  self._connection = self.connection_factory.create_connection(
91
94
  uri=uri,
92
95
  on_connection_open=self.on_connection_open,
@@ -129,6 +132,33 @@ class AsyncConnection:
129
132
  signal=self.signal,
130
133
  )
131
134
  self._channel.publisher_confirms = self.publisher_confirms
135
+
136
+ if self.reconnecting or self.backup["subscribe"] or self.backup["rpc_subscribe"]:
137
+ async def recorvery():
138
+ for routing_key in list(self.backup["subscribe"].keys()):
139
+ params = self.backup["subscribe"][routing_key]
140
+ await self.subscribe(
141
+ params["queue_name"],
142
+ params["exchange_name"],
143
+ routing_key,
144
+ params["callback"],
145
+ params["timeout"],
146
+ )
147
+ for routing_key in list(self.backup["rpc_subscribe"].keys()):
148
+ params = self.backup["rpc_subscribe"][routing_key]
149
+ await self.rpc_subscribe(
150
+ params["queue_name"],
151
+ params["exchange_name"],
152
+ routing_key,
153
+ params["callback"],
154
+ params["timeout"],
155
+ )
156
+
157
+ future: Future = Future(loop=self.ioloop)
158
+ self.callbacks.append((recorvery, future))
159
+ self.reconnect_delay = 1
160
+ self.reconnecting = False
161
+
132
162
  self._channel.open(self._connection, self.callbacks)
133
163
 
134
164
  def on_connection_open_error(self, _unused_connection, err):
@@ -193,30 +223,30 @@ class AsyncConnection:
193
223
  )
194
224
  self.reconnect_delay += 1
195
225
  else:
196
-
197
- async def recorvery():
198
- for routing_key in self.backup["subscribe"]:
199
- params = self.backup["subscribe"][routing_key]
200
- await self.subscribe(
201
- params["queue_name"],
202
- params["exchange_name"],
203
- routing_key,
204
- params["callback"],
205
- params["timeout"],
206
- )
207
- for routing_key in self.backup["rpc_subscribe"]:
208
- params = self.backup["rpc_subscribe"][routing_key]
209
- await self.rpc_subscribe(
210
- params["queue_name"],
211
- params["exchange_name"],
212
- routing_key,
213
- params["callback"],
214
- params["timeout"],
215
- )
216
-
217
- self.ioloop.create_task(self.add_callback(recorvery)) # type: ignore
218
- self.reconnect_delay = 1
219
- self.reconnecting = False
226
+ if self.reconnecting:
227
+ async def recorvery():
228
+ for routing_key in list(self.backup["subscribe"].keys()):
229
+ params = self.backup["subscribe"][routing_key]
230
+ await self.subscribe(
231
+ params["queue_name"],
232
+ params["exchange_name"],
233
+ routing_key,
234
+ params["callback"],
235
+ params["timeout"],
236
+ )
237
+ for routing_key in list(self.backup["rpc_subscribe"].keys()):
238
+ params = self.backup["rpc_subscribe"][routing_key]
239
+ await self.rpc_subscribe(
240
+ params["queue_name"],
241
+ params["exchange_name"],
242
+ routing_key,
243
+ params["callback"],
244
+ params["timeout"],
245
+ )
246
+
247
+ self.reconnect_delay = 1
248
+ self.reconnecting = False
249
+ self.ioloop.create_task(self.add_callback(recorvery)) # type: ignore
220
250
 
221
251
  @property
222
252
  def is_open(self) -> Optional[bool]:
@@ -464,7 +494,7 @@ class AsyncConnection:
464
494
  >>> result = await connection.add_callback(my_operation, 10.0)
465
495
  """
466
496
  try:
467
- if self.is_open and self._channel.is_open:
497
+ if self.is_open and self._channel and self._channel.is_open:
468
498
  return await callback()
469
499
  else:
470
500
  future: Future = Future(loop=self.ioloop)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amqp-client-python
3
- Version: 0.2.0.post1
3
+ Version: 0.2.1.dev1
4
4
  Summary: Python AMQP Client Library
5
5
  Project-URL: Homepage, https://github.com/nutes-uepb/amqp-client-python
6
6
  Project-URL: Repository, https://github.com/nutes-uepb/amqp-client-python
@@ -17,7 +17,6 @@ Classifier: License :: OSI Approved :: Apache Software License
17
17
  Classifier: Natural Language :: English
18
18
  Classifier: Operating System :: OS Independent
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.8
21
20
  Classifier: Programming Language :: Python :: 3.9
22
21
  Classifier: Programming Language :: Python :: 3.10
23
22
  Classifier: Programming Language :: Python :: 3.11
@@ -1,14 +1,14 @@
1
- amqp_client_python/__init__.py,sha256=6kv8G2KlcvbSVIE8Inxb3ugMNSTjg7KK9_HvyDprfb8,213
1
+ amqp_client_python/__init__.py,sha256=XUO7lawlYTTqfS2-oxRmviPz0_KqwIeD1IpugdzZm4U,401
2
2
  amqp_client_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  amqp_client_python/signals.py,sha256=6mW4oWBQnbJwuKox6ceeDbxTM8v9aCDEb0o2zyhpb5g,1263
4
- amqp_client_python/domain/models/__init__.py,sha256=T57j9Sr5Z0pWyGT598CpAx_KhoV-MVpgHTvfESZAa90,92
4
+ amqp_client_python/domain/models/__init__.py,sha256=EgEV-FeMUVMj_7RvhPbnZaqnJaNqTYnIAiEiqSy0ies,154
5
5
  amqp_client_python/domain/models/config.py,sha256=g2AWrlEvHCS1h2zlny29phREyG9GmD0rtGQHS3C7LVU,2268
6
6
  amqp_client_python/domain/models/options.py,sha256=lx-x4uyMpyjelZjMuyUxLsORz1ro1vDjD33j0EGYD-o,2141
7
7
  amqp_client_python/domain/models/ssl_options.py,sha256=xOTSIKfbNZbYepY6o3SxuZvLPX3J5pvRoJXIJlyBsrI,613
8
- amqp_client_python/domain/utils/__init__.py,sha256=ppob9KPfzq9K3Fd2-RJr6CnwmPDOdgaAzPqOV0Q17P0,75
8
+ amqp_client_python/domain/utils/__init__.py,sha256=lZL3bwchrTiiKx5d1RSVUJACAuPb7zOnoH9tZ65t_Ok,131
9
9
  amqp_client_python/domain/utils/connection_type.py,sha256=AnEF8Nd3cQBCGX8rPKwEkKts8kwnGUAVr0nxnbpynLE,164
10
10
  amqp_client_python/domain/utils/types.py,sha256=veT5lgZhUxophpmWItYaz56XxJTXGJ2L6J6oG_TbSWs,160
11
- amqp_client_python/event/__init__.py,sha256=VxqWqZLw2od3bxGHmf2d2I6QOctJNxUEP8lmjPELHF4,325
11
+ amqp_client_python/event/__init__.py,sha256=vx6_rIQ94xdsPpNBq0peTEDqSU90UNh9YBk1tq5MALg,501
12
12
  amqp_client_python/event/async_provider_handler.py,sha256=tncL6X6R9cLLBZLeZ3xsl2ZJVj6Ag84wq79hNRWZSpc,228
13
13
  amqp_client_python/event/async_subscriber_handler.py,sha256=bsoX5WDAlRwTnZXy_9xwn4rz29Mj1Sci6v36wkzwlnU,210
14
14
  amqp_client_python/event/event.py,sha256=2CSRJJMDI6AZDkO4eXAQdVSW38bdE-CcfbJTdK--cc0,115
@@ -16,7 +16,7 @@ amqp_client_python/event/integration_event.py,sha256=lVBVA4hnZA77_XrS26yWhegK4n9
16
16
  amqp_client_python/event/integration_event_handler.py,sha256=eW6m0SD48J0yJhnYFchMHTs1TgQIFLmoRu_xnOyRRXQ,165
17
17
  amqp_client_python/event/provider_handler.py,sha256=F8M3XhULNZdta9_OLbOqLoeLXw9WIEeucemGjVPmdWQ,217
18
18
  amqp_client_python/event/subscriber_handler.py,sha256=0bb_76kIAofBvBtZvQ2SM2n6e-Ip-L8JA0NvxmimLgc,199
19
- amqp_client_python/exceptions/__init__.py,sha256=86fPynIGbtWiERWOkpdW5YZjg50LHLaATs8K4odUlMs,495
19
+ amqp_client_python/exceptions/__init__.py,sha256=mBe8Cuir3H5ULHgzRPio05aqRDlcrTDToM4DAfPV3V8,755
20
20
  amqp_client_python/exceptions/auto_reconnect_exception.py,sha256=20E806dFoRQcDhdFd0wZWM-QmsxTAKCotZqfepuyNXk,277
21
21
  amqp_client_python/exceptions/blocking_exception.py,sha256=QAEIe20r-ND6FOfJTmFdK4ezjHeDr-SJsrWnbXNfal0,277
22
22
  amqp_client_python/exceptions/eventbus_exception.py,sha256=999Pn1HPCb_k-0zGUVE4wJo94vLQDZamoZcYHVXRmCI,217
@@ -26,10 +26,10 @@ amqp_client_python/exceptions/response_timeout_exception.py,sha256=us_PiJPSk1pnz
26
26
  amqp_client_python/exceptions/rpc_provider_exception.py,sha256=_1Ytb8BOUT_9xEtG_ibGx3cEMMM4kUVtduEVtXn-d6M,280
27
27
  amqp_client_python/exceptions/thread_unsafe_exception.py,sha256=zcC4VyuxXWo66Tts1AQtkg07GK3OjXu3LEtt1AUj4jk,281
28
28
  amqp_client_python/exceptions/timeout_exception.py,sha256=0YT-vivS44mHF4Jc3o2rlZFc6l_zzNjcxCHPS9ArgN0,271
29
- amqp_client_python/rabbitmq/__init__.py,sha256=ZFaBSr8TDzZlHwaT344ao20W2FD5c3RI2sa5kiEeKeI,630
30
- amqp_client_python/rabbitmq/async_channel.py,sha256=OtW0agoSMG-v38lKJsFNRMaFoqubEauQCmLaLN7bQek,26667
29
+ amqp_client_python/rabbitmq/__init__.py,sha256=4N-j8rbrJj0kOOSIhSWJenj6JOJbzFNnW3bxwPGTyuM,941
30
+ amqp_client_python/rabbitmq/async_channel.py,sha256=7QQTKqqe5uFBr9TqUOS0X0tMEMNJavstRnQ9RHWl2wA,26926
31
31
  amqp_client_python/rabbitmq/async_channel_factory.py,sha256=ec_5B3Sgazi_ncIG5lI5nnmkH3NprwvyjMhvgpG1BWA,371
32
- amqp_client_python/rabbitmq/async_connection.py,sha256=lWArTU5lXKMrKnnTivhrWs8c9PJnUNMAD5_QI3FZu-s,16906
32
+ amqp_client_python/rabbitmq/async_connection.py,sha256=p05Y_1iXcytROZuaPqmodlKxsdxU50ALhEDjN7WqEhw,18308
33
33
  amqp_client_python/rabbitmq/async_connection_factory.py,sha256=3N5MM1fPUdodAFLh58rf6vvwN9OAclDVzmG85Qve-Ss,849
34
34
  amqp_client_python/rabbitmq/async_eventbus_rabbitmq.py,sha256=4PCtqhVNT3cq-d0anfdKPzhmmETD-HMqIu-MVuZmZZA,12950
35
35
  amqp_client_python/rabbitmq/channel_factory_rabbitmq.py,sha256=h_vGqHgL0DOtXC0tmVd5gzXVlNKL48rxpKpwaN3AlOM,310
@@ -39,7 +39,7 @@ amqp_client_python/rabbitmq/connection_rabbitmq.py,sha256=9A8NAPAB3i-5E43SV5sxjK
39
39
  amqp_client_python/rabbitmq/eventbus_rabbitmq.py,sha256=GZoJGVeBkMTPrQ5dIJqad-MdGmuuJsxGaXV1YGLdk5o,6980
40
40
  amqp_client_python/rabbitmq/eventbus_wrapper_rabbitmq.py,sha256=i3C-sZO9EifanfRXReiib56fxxzjV3Cx71rdbJORg78,7442
41
41
  amqp_client_python/rabbitmq/ioloop_factory.py,sha256=vfgndKLcazQU0a4elI5RNHnQCTEua--Jjo99bzX8iHo,856
42
- amqp_client_python-0.2.0.post1.dist-info/METADATA,sha256=w5Hdo9NIX282a9bOtOVK-AIJvvRLU0aUBjr4LPxr2ys,10206
43
- amqp_client_python-0.2.0.post1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
44
- amqp_client_python-0.2.0.post1.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
45
- amqp_client_python-0.2.0.post1.dist-info/RECORD,,
42
+ amqp_client_python-0.2.1.dev1.dist-info/METADATA,sha256=1PF9aIMEadkewz66TXxQLkFKeYKU6UtEzrbE6VHHRAw,10155
43
+ amqp_client_python-0.2.1.dev1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
44
+ amqp_client_python-0.2.1.dev1.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
45
+ amqp_client_python-0.2.1.dev1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.29.0
2
+ Generator: hatchling 1.31.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any