noticing 'client_disconnect' event doesn't work while background task is running in the loop #2182
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @Roz-floatic! The background job should not have any effect on disconnected event which makes me think your job may be blocking and is not background at all. Could you maybe create a min repro example so that we have something tangible to discuss?
Is the data displayed scoped to user or are global (every user sees the same data)? |
Beta Was this translation helpful? Give feedback.
Okay, found the problem: The code above was creating an infinite loop on client initialization, which is fine as long as it uses
asyncio.sleep
that can suspend asyncio task execution. However, the problem was that the code never ran beyond theinit
function (due to infinite loop) thus could not mark the client initialization as done (q.client.initialized = True
). This caused 2 problems:init
function, therun_on
would never be called, thus neither routing, nor disconnected handler woul…