python-mpd2
python-mpd2 copied to clipboard
Delay of 0.1 seconds between asyncio MPD commands causes hang
Consider this snippet:
import asyncio
import mpd.asyncio
async def main():
client = mpd.asyncio.MPDClient()
await client.connect("192.168.0.2", 6600)
for _ in range(2):
print("Status:")
print((await client.status())["state"])
await asyncio.sleep(0.1)
asyncio.run(main())
Running this with Python 3.9.5 and python-mpd2 3.0.4, I get this output:
Status:
stop
Status:
At this point, the second call to client.status() never completes, and the program hangs. If the 0.1 second delay is changed to any other value, the problem goes away. It seems like this is some kind of race condition with IMMEDIATE_COMMAND_TIMEOUT.