Exiting the socket is being delayed
I dont think the issue existed before, but I recently found that the socket (either ReconnectingSocket or KeepAliveSocket), the __aexit__ is always delayed for exact 10 seconds:
async with socket:
print('done')
print('close') # this message is always 10 secs late after the 'done' message
I dig a little bit of the code and I think it is because the socket is waiting for data in the _read_loop:
res = await asyncio.wait_for(
self.ws.recv(), timeout=self.TIMEOUT
)
and self.TIMEOUT is 10, which explains the 10 secs delay.
Am I right? And how do you remove the delay?
Hi @tsunamilx ,
Correct, on exit we kill the read loop, which if it's streaming it would wait till the next message or the timeout to go over the loop and exit. Would editing the value of self.TIMEOUT to a smaller value work for you?
Hi @pcriadoperez , yes, editing self.TIMEOUT to a smaller value would work, I guess this is only way for now.
This issue didn't exist before if I remember correctly, what's changed and what was the problem before the change?
Thanks.