Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env (interactive mode): timeout for blocking operations #440

Open
wants to merge 3 commits into
base: spr/mtrofin/main.env-interactive-mode-timeout-for-blocking-operations
Choose a base branch
from

Conversation

mtrofin
Copy link
Collaborator

@mtrofin mtrofin commented Feb 12, 2025

The opening of the communication named pipes and the
read operations are blocking. This introduces a timeout.

High level:

  • we associate a thread with open, which waits for a signal
    (Event), with a timeout. If it times out, the thread opens
    the associated pipe, which unblocks the main open

  • writes aren't expected to block

  • reads are. To address, we poll (select.select) before reading,
    with a timeout.

The design treats the timeout as resetting for each blocking op.
This is just to simplify the design - rather than checking passed
time.

Created using spr 1.3.5
Created using spr 1.3.5
Created using spr 1.3.5
@mtrofin mtrofin requested a review from svkeerthy February 12, 2025 20:43
Copy link
Collaborator

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Some initial comments. i'd like to go through the tests a bit more thoroughly when I have chance.

compiler_opt/rl/env.py Show resolved Hide resolved
return _replacement

# pylint: disable=protected-access
obj._orig_read = obj.read
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why exactly do these need to be put into protected members before being passed to _replacement(*)? It doesn't seem like they have any other users.

opened = threading.Event()
timed_out = threading.Event()

# same idea as in the writer case - unblock the `open`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this isn't worth factoring out due to all the differences in logging messages?

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