Skip to content

Commit

Permalink
Introduced a sleep in the threaded readout function, as well as non-b…
Browse files Browse the repository at this point in the history
…locking queue put of read messages
  • Loading branch information
Paul Nilsson committed Dec 11, 2024
1 parent 7e441d9 commit 1612a2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PILOTVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.3.1
3.9.3.2
2 changes: 1 addition & 1 deletion pilot/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
RELEASE = '3' # released number should be fixed at 3 for Pilot 3
VERSION = '9' # version number is '1' for first release, '0' until then, increased for bigger updates
REVISION = '3' # revision number should be reset to '0' for every new version release, increased for small updates
BUILD = '1' # build number should be reset to '1' for every new development cycle
BUILD = '2' # build number should be reset to '1' for every new development cycle

SUCCESS = 0
FAILURE = 1
Expand Down
9 changes: 5 additions & 4 deletions pilot/util/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,22 @@ def execute(executable: Any, **kwargs: dict) -> Any: # noqa: C901

def read_output(stream, queue):
while True:
sleep(0.01)
try:
line = stream.readline()
if not line:
break
except (AttributeError, ValueError):
# Handle the case where stream is None (AttributeError) or closed (ValueError)
break
except OSError as e:
if e.errno == errno.EBADF:
# Handle the case where the file descriptor is bad
break
else:
raise

queue.put(line)
try:
queue.put_nowait(line)
except queue.Full:
sleep(0.01) # Sleep for a short interval to avoid busy waiting

stdout_thread = threading.Thread(target=read_output, args=(process.stdout, stdout_queue))
stderr_thread = threading.Thread(target=read_output, args=(process.stderr, stderr_queue))
Expand Down

0 comments on commit 1612a2f

Please sign in to comment.