Asynchronous MPD client library
Project description
ampd - Asynchronous MPD client library
Communicate with a Music Player Daemon server using asyncio.
Connection is established by a client object. Requests (MPD commands) are generated by executor objects, and are awaited for in asyncio coroutines. Each client has a root executor, and sub-executors can be constructed for grouping related requests.
Tasks
An AMPD task is an asyncio coroutine decorated by @ampd.task
.
The decorator ensures that the task is immediately scheduled for execution, and
that cancellation (e.g., on close()ing the executor) is considered normal termination:
@ampd.task
async def task_example():
...
reply = await executor.request1(a, b)
...
reply = await executor.request2()
...
The request can be:
a. An MPD command (other than idle
or noidle
).
Returns when the server's reply arrives:
await executor.play(5)
reply = await executor.status()
b. 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) orANY
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.
c. Command list: executor.command_list(iterable)
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ampd-0.2.12.tar.gz
.
File metadata
- Download URL: ampd-0.2.12.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd804e97d0c707f91964687ce3070910275536caf1053cf6401f8251d6061afa |
|
MD5 | 3087c8edc0403a4019869a59bf563d69 |
|
BLAKE2b-256 | 615cfe90428aca9c09360bb5930e67f21a93498670d63c971b3afc54a9161808 |