Socket remaining open while getting logs from Generator object
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
As per this documentation, I was using client.services.create method for creating the service in existing swarm network. The service was created successfully.
After that I tried to fetch the the logs using logs method of Service object. The parameters which I used in logs method were (follow=True, stdout=True, stderr=True). I kept follow=True as I wanted to fetch the logs as the execution of commands is done. I fetched the logs from generator object using for loop.
my_srv = client.services.create(.......)
logs = my_srv.logs(follow=True, stdout=True, stderr=True)
for log in logs:
print(log)
When the execution of service is completed, at that time the socket remains open of generator object. Due to that, the for loop execution does not get completed even if the logs are over.
Currently I have handled this using thread deamon process which will be killed as soon as the execution of service is completed. But is there any other workaround?
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
Start with Service.logs(follow=True, stdout=True, stderr=True) and the generator loop shown in the issue. Investigate how log streaming behaves after the service completes and verify whether the underlying socket is closed. Done means identifying a supported behavior or reproducible fix so the generator terminates when logs are exhausted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100