python-mpd2 icon indicating copy to clipboard operation
python-mpd2 copied to clipboard

Delay of 0.1 seconds between asyncio MPD commands causes hang

Open dphoyes opened this issue 4 years ago • 0 comments

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.

dphoyes avatar Jun 01 '21 21:06 dphoyes