container.logs(stream=True) delayed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
docker-py: 4.2.0
OS: Windows 10
Docker: 2.3.0.2
Engine: 19.03.8
I have a simple code to read a stream of logs from a specific container. I am setting stream=True to continuously read new logs as they're logged. However, it appears that the SDK receives (or prints) logs with a "delay".
If the stream of logs in the monitored container is regular and continuous, the monitoring container with python SDK running prints new logs every ~5 seconds. When monitoring other containers that write into stdout rarely, it appears that the container.logs function waits for a certain volume of logs to be collected before releasing the next logs entry.
for log in container.logs(stream=True, stdout=True, stderr=True):
print(log)
I would like to know why I'm seeing a delay in the logs stream, and whether I can change it via configuration.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the delay with container.logs(stream=True, stdout=True, stderr=True) using both continuously writing and rarely writing containers. Start by determining whether buffering occurs in the Python SDK or the Docker Engine API. Done means explaining the source of the delay and identifying whether a configuration can change it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100