Lancetnik / Propan

Propan is a powerful and easy-to-use Python framework for building event-driven applications that interact with any MQ Broker
https://lancetnik.github.io/Propan/
MIT License
487 stars 28 forks source link

Bug: Pydantic v1 'RabbitQueue' object has no attribute 'routing_key' #136

Closed Llewe closed 1 year ago

Llewe commented 1 year ago

Describe the bug When using PydanticV1 (i used 1.10.12) the RabbitRouter feature doesn't work with the @router.handle decorator.

To Reproduce

  1. install pydantic 1.10.12
  2. run code
    
    import asyncio
    from propan.brokers.rabbit import RabbitExchange, RabbitQueue
    from propan import PropanApp, RabbitBroker, RabbitRouter

broker = RabbitBroker() router = RabbitRouter()

queue = RabbitQueue( name="job.single", routing_key="job.single", auto_delete=True, )

exchange = RabbitExchange(name="test")

@router.handle(queue=queue, exchange=exchange) async def handler(): print("handler")

broker.include_router(router) app = PropanApp(broker)

if name == "main": print("starting") asyncio.run(app.run())


**Environment**
Running Propan 0.1.5.23 with CPython 3.11.5 on Linux

**Additional context**
I know v1 is outdated but for now i can't switch to v2 since a lib we use is currently v1 only.

** Error Log**
The error i get (i replaced the absolute paths)

Traceback (most recent call last): File "project_folder/.venv/lib/python3.11/site-packages/propan/cli/app.py", line 219, in run await self._stop(log_level) File "project_folder/.venv/lib/python3.11/site-packages/propan/cli/app.py", line 233, in _stop await self._stop_event.wait() File "project_folder/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1621, in wait await self._event.wait() File "/usr/lib/python3.11/asyncio/locks.py", line 213, in wait await fut asyncio.exceptions.CancelledError: Cancelled by cancel scope 7fc8dc79bed0

During handling of the above exception, another exception occurred:

Lancetnik commented 1 year ago

@Llewe Thanks for the bug reporting Just update Propan to 0.1.5.24 version - your examples works fine on it

Llewe commented 1 year ago

Perfect! Thanks for the quick fix and for this awesome project