Skip to content

Specify timeout when running cmd_list in CleanUnknownWorker#182

Open
FrostyX wants to merge 1 commit intopraiskup:mainfrom
FrostyX:cmd-list-timeout
Open

Specify timeout when running cmd_list in CleanUnknownWorker#182
FrostyX wants to merge 1 commit intopraiskup:mainfrom
FrostyX:cmd-list-timeout

Conversation

@FrostyX
Copy link
Copy Markdown
Collaborator

@FrostyX FrostyX commented Apr 2, 2026

Fix #178

Comment thread resallocserver/manager.py Fixed
@FrostyX FrostyX force-pushed the cmd-list-timeout branch from 48a3478 to a29dcc0 Compare April 2, 2026 11:33
Comment thread resallocserver/manager.py Outdated

for line in iter(sp.stdout.readline, b''):
captured_string = b""
for line in lines:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has never worked for me when it comes to "live logs". I'd swear I tried PYTHONUNBUFFERED, too -- I'm a bit afraid to touch those lines :-/

Comment thread resallocserver/manager.py Outdated
stdout=subprocess.PIPE, stderr=logfile) as sp:
captured_string = b""
try:
stdout, _stderr = sp.communicate(timeout=timeout)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may lead to an OOM error, if the tooling behind gets mad and provides GBs on a single line.

Comment thread resallocserver/manager.py Outdated

# When the command is written in Python, it probably buffers its output
# and therefore it could be empty in case the subprocess it timeouts.
env["PYTHONUNBUFFERED"] = "1"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you aim at subprocesses here?

@FrostyX
Copy link
Copy Markdown
Collaborator Author

FrostyX commented Apr 24, 2026

I have an easy reproducer with all corner-cases here
https://gist.github.com/FrostyX/73379ff510cd7acf897925199575299e

I am planning to incorporate the code into this PR if we agree that the approach is correct.

Comment thread resallocserver/manager.py
# We encountered EOF but we still have unprocessed bytes
elif buffer:
# Treat partial line as a complete line
# TODO do we want this or rather discard the incomplete line?
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.

Can't close tickets because of xmlrpc timeout

3 participants