Get docker container logs via python SDK asynchronously

All the examples I’ve found of using the Python Docker SDK to retrieve container logs is of the following:

client = docker.APIClient(base_url='tcp://localhost:2375')
client.attach('my_container')
for log in client.logs('my_container', stdout=True, stream=True):
    print(log)

Is there a way to get docker container logs asynchronously?
I’m looking for something like this:

while True:
    line = await client.logs('my_container', stdout=True, stream=True)
    print(line)
    await asyncio.sleep(1)
1 Like