Skip to main content

Asynchronous MPD client library

Project description

Uses python asyncio for asynchronous communication with a Music Player Daemon server.

Connection is established by a client object. Requests (MPD commands) are executed in asyncio coroutines, referred to here as “tasks”. Requests are generated by an executor object. Each client has a root executor, and sub-executors can be constructed (for grouping related tasks).


An AMPD task is, essentially, an asyncio coroutine. The @task decorator makes the coroutine execute immediately via asyncio.ensure_future. In addition, it wraps it so cancellation and disconnect exceptions are considered normal termination:

async def task_example():
    reply = await executor.request1(a, b)
    reply = await executor.request2()

The request can be:

  1. An MPD command [1] (other than idle and noidle). Returns when the server’s reply arrives:

    reply = await executor.status()
  2. Idle request:

    reply = await executor.idle(event_mask, timeout=None)

    This emulates MPD’s idle command, with some improvements. The timeout is given in seconds. Possible event flags are:

    • Event.*SUBSYSTEM* (in uppercase) or ANY to match any subsystem.
    • Event.CONNECT - client is connected to server.
    • Event.IDLE - client is idle.

    Returns the mask of events which actually occurred, or Event.TIMEOUT if timeout occurred.

  3. Command list: executor.command_list(iterable).

[1]For MPD commands and subsystems see

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ampd, version 0.2.10
Filename, size File type Python version Upload date Hashes
Filename, size ampd-0.2.10.tar.gz (11.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page