]> kaliko git repositories - python-musicpdaio.git/blob - doc/source/tutorial/tutorial-01.py
Add Sphinx documentation
[python-musicpdaio.git] / doc / source / tutorial / tutorial-01.py
1 import asyncio
2 import logging
3
4 from mpdaio.client import MPDClient
5
6 # Configure loggers
7 logging.basicConfig(level=logging.INFO, format='%(levelname)-8s %(message)s')
8 logging.getLogger("asyncio").setLevel(logging.WARNING)
9 # debug level level will show where defaults settings come from
10 log = logging.getLogger('mpdaio.client')
11 log.setLevel(logging.DEBUG)
12
13
14 async def run():
15     # Use defaults to access MPD server
16     client = MPDClient()
17
18     # Make an initial connection to MPD server
19     # The connection is kept open an reused for later commands
20     await client.ping()
21
22     # Each task gathered here will run with it's own connection
23     await asyncio.gather(...)
24
25     # Closes all connections to MPD server
26     await client.close()
27
28
29 if __name__ == '__main__':
30     asyncio.run(run())