rdfsx / aiogram-template

MIT License
42 stars 5 forks source link

webhooks using #12

Open mixartemev opened 2 years ago

mixartemev commented 2 years ago

It's the best template for aiogram3.0 I could find! But can you please to privide minimal example within webhook updates?

mixartemev commented 2 years ago

I've implemented webhooks as it is shown at aiogram3.0 example but in this case mongo fsm storage is crashes due to some low-level asynchronous things that I didn't understand, with error: RuntimeError: Task <Task pending name='Task-11' coro=<BaseRequestHandler._background_feed_update() running at /Volumes/Home/Library/Caches/pypoetry/virtualenvs/aiogram-template-VZ-Pzham-py3.10/lib/python3.10/site-packages/aiogram/dispatcher/webhook/aiohttp_server.py:124>> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/Cellar/python@3.10/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/futures.py:384]> attached to a different loop

Screenshot 2022-02-08 at 12 17 38

But still it's working fine with other fsm storages like redis. So I'm curious how to fix working with mongo storage because it's actually pretty convenient way to use fsm storage.

rdfsx commented 2 years ago

It's the best template for aiogram3.0 I could find! But can you please to privide minimal example within webhook updates?

Hi! I have never implemented webhooks in aiogram 3. Maybe I will in the future.

rdfsx commented 2 years ago

I've implemented webhooks as it is shown at aiogram3.0 example but in this case mongo fsm storage is crashes due to some low-level asynchronous things that I didn't understand, with error: RuntimeError: Task <Task pending name='Task-11' coro=<BaseRequestHandler._background_feed_update() running at /Volumes/Home/Library/Caches/pypoetry/virtualenvs/aiogram-template-VZ-Pzham-py3.10/lib/python3.10/site-packages/aiogram/dispatcher/webhook/aiohttp_server.py:124>> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/Cellar/python@3.10/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/futures.py:384]> attached to a different loop Screenshot 2022-02-08 at 12 17 38 But still it's working fine with other fsm storages like redis. So I'm curious how to fix working with mongo storage because it's actually pretty convenient way to use fsm storage.

I think this is because storage is implemented without real locks, but using asyncio Lock instead. I have not tried to implement locks in mongo yet, so I advise you to use either redis or polling

rdfsx commented 2 years ago

Are you sure you need webhooks? In my experience, the only time they're useful is when you're highloading and need to proxy requests to multiple bot instances. But I mean really high load