Replies: 3 comments
-
Please close the issue if it is solved. |
Beta Was this translation helpful? Give feedback.
-
|
@coder3122 will do - was leaving it open in case anyone had any advice on using async in this scenario |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the help here @coder3112 ! 👏 🙇 Thanks for reporting back and closing the issue @dbatten5 👍
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Most likely this is an issue with my current setup, I'm quite new to async python so I'm sure I'm missing some conceptual things.
My use case is:
progressattribute in aJobmodel and sleeps for a bit to avoid getting rate limited by an external serviceprogressback to the client via a websocketExample
This is just to illustrate the problem, won't work as is
Description
The background task is kicked off fine and the database entries are added as expected. However when I open the websocket the background task seems to pause and remains paused until the websocket is closed. At that point the background task starts again and carries on as normal. How can I open the websocket without causing the task to stop execution?
I read somewhere about using
asyncio.ensure_futurebut I'm not quite sure how to use it in this context. Also quite unsure about my current setup and whether the task should be async. When I switch it toasync def(andawait asyncio.sleep(20)) though the post request takes a long time to return a response.Environment
Thanks in advance for any help
UPDATE
After adding some logging to my job it turns it is was actually being run, it's just that the job I was fetching from the database before sending a message through the websocket wasn't updated with the latest progress. After running a
db.refresh(job)it worked.Beta Was this translation helpful? Give feedback.
All reactions