-
Notifications
You must be signed in to change notification settings - Fork 95
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
base: spr/mtrofin/main.env-interactive-mode-timeout-for-blocking-operations
Are you sure you want to change the base?
Conversation
Created using spr 1.3.5
Created using spr 1.3.5
There was a problem hiding this 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.
return _replacement | ||
|
||
# pylint: disable=protected-access | ||
obj._orig_read = obj.read |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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?
The
open
ing of the communication named pipes and theread
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.