You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But we faced with problem, that nested routers duplicates consumer instances, which cause multiple reading and processing one message from topic:
test-faststream-py3.11➜ test-faststream uvicorn main:app
INFO: Started server process [53140]
INFO: Waiting for application startup.
2024-08-30 11:48:03,740 INFO - test | - `Hello` waiting for messages
2024-08-30 11:48:03,749 INFO - test | - `Hello` waiting for messages
2024-08-30 11:48:03,749 INFO - test | - `Hello` waiting for messages
and cause aiokafka error on shutdown:
Unclosed AIOKafkaConsumer
consumer: <aiokafka.consumer.consumer.AIOKafkaConsumer object at 0x7b93128ff590>
test-faststream-py3.11➜ test-faststream uvicorn main:app
INFO: Started server process [56711]
INFO: Waiting for application startup.
2024-08-30 12:07:48,342 INFO - test | - `Hello` waiting for messages
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
2024-08-30 12:07:55,098 INFO - test | 0-17250088 - Received
2024-08-30 12:07:55,101 INFO - test | 0-17250088 - m={'abc': 25}
2024-08-30 12:07:55,101 INFO - test | 0-17250088 - Processed
Observed behavior
test-faststream-py3.11➜ test-faststream uvicorn main:app
INFO: Started server process [56100]
INFO: Waiting for application startup.
2024-08-30 12:06:14,196 INFO - test | - `Hello` waiting for messages
2024-08-30 12:06:14,204 INFO - test | - `Hello` waiting for messages
2024-08-30 12:06:14,204 INFO - test | - `Hello` waiting for messages
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Unclosed AIOKafkaConsumer
consumer: <aiokafka.consumer.consumer.AIOKafkaConsumer object at 0x778c46fbf650>
2024-08-30 12:06:16,150 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,150 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,150 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,150 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,153 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,153 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,153 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,153 INFO - test | 0-17250087 - Received
2024-08-30 12:06:16,154 INFO - test | 0-17250087 - m={'abc': 25}
2024-08-30 12:06:16,154 INFO - test | 0-17250087 - m={'abc': 25}
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - m={'abc': 25}
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - m={'abc': 25}
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
2024-08-30 12:06:16,155 INFO - test | 0-17250087 - Processed
Environment
Running FastStream 0.5.19 with CPython 3.12.5 on Linux
Hi! Thank you for the report
The problem is related to latest FastAPI 0.112.2 release
I fixes it already in latest commit, please wait for 0.5.20 FastStream release and check it again (I plan to release it this evening)
Describe the bug
According to your documentation https://faststream.airt.ai/latest/getting-started/integrations/fastapi/#routers-nesting, we wanted to create fastapi-like routers structure to separate subscribers for different topics:
But we faced with problem, that nested routers duplicates consumer instances, which cause multiple reading and processing one message from topic:
and cause aiokafka error on shutdown:
How to reproduce
Include source code:
And/Or steps to reproduce the behavior:
Expected behavior
Observed behavior
Environment
Running FastStream 0.5.19 with CPython 3.12.5 on Linux
The text was updated successfully, but these errors were encountered: