Skip to content

Conversation

@kasium
Copy link
Contributor

@kasium kasium commented Dec 1, 2025

The return types of docker exec_start are always bytes to my experiments

from __future__ import annotations

from docker import APIClient

client = APIClient()

container_id = client.create_container("python:3.12", command="sleep 10")
client.start(container_id)

try:
    exec_id = client.exec_create(container_id, "echo hello")
    res = client.exec_start(exec_id)
    print(type(res))

    exec_id = client.exec_create(container_id, "echo hello")
    res = client.exec_start(exec_id, stream=True)
    print(type(next(res)))

    exec_id = client.exec_create(container_id, "echo hello")
    res = client.exec_start(exec_id, socket=True)
    print(type(next(res)))

    exec_id = client.exec_create(container_id, "echo hello")
    res = client.exec_start(exec_id, demux=True)
    print(type(res[0]))

    exec_id = client.exec_create(container_id, "echo hello")
    res = client.exec_start(exec_id, demux=True, stream=True)
    print(type(next(res)[0]))
finally:
    client.stop(container_id)

Output:

<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>
<class 'bytes'>

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@kasium
Copy link
Contributor Author

kasium commented Dec 1, 2025

Let me have a look on the failed runs

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit cb592d4 into python:main Dec 1, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants