Mic92 / python-mpd2

Python library which provides a client interface for the Music Player Daemon.
GNU Lesser General Public License v3.0
352 stars 119 forks source link

Delay of 0.1 seconds between asyncio MPD commands causes hang #173

Closed dphoyes closed 1 month ago

dphoyes commented 3 years ago

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.

chrysn commented 1 month ago

As far as I understand, this was fixed in #199 by @yakshaver2000 and can thus be closed. Sorry for the bug, thanks for finding and fixing it!