JurgenR / aioslsk

SoulSeek client library using Python asyncio
GNU General Public License v3.0
17 stars 0 forks source link

Network: Keep connection open when only sending messages #288

Closed JurgenR closed 1 month ago

JurgenR commented 1 month ago

When porting to asyncio from selectors the connection code was nearly completely rewritten, the old code would hold the last interaction time and decide on that value whether to timeout the connection. This value would get updated when sending or receiving messages. Due to asyncio.Timeout being only available in Python 3.11 and the library supporting older versions this was forgotten.

Currently for messaging connections (file connections should be checked again) the connection will timeout even when sending data over the connection. This mostly impacts distributed connections for children, there is enough back and forth on the server / peer connections that it is not noticeable there.

Due to an issue with asyncio.wait_for in older Python versions the library now uses a backport library async-timeout on which the timeout could increased using the .shift() method

JurgenR commented 1 month ago

Normalized the timeouts a little bit but need to revisit the connection code at some point. Works but for people reading it might be unclear.