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

don't throw EOFError from sleep #54801

Closed
wants to merge 1 commit into from
Closed

don't throw EOFError from sleep #54801

wants to merge 1 commit into from

Conversation

stevengj
Copy link
Member

This prevents sleep from throwing an EOFError under rare conditions (with very short timer durations) where the Timer object is already closed before it can be signaled, which seems like a bug.

See the discourse discussion.

@stevengj stevengj added the bugfix This change fixes an existing bug label Jun 14, 2024
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

This is not the correct fix, but it seems like it should work around the bug in most cases

@oscardssmith
Copy link
Member

why isn't this a correct fix?

@stevengj
Copy link
Member Author

stevengj commented Jun 17, 2024

It seems like a better fix would make wait(Timer(sec)) safe, somehow.

Timer is an exported API, so ideally calling wait on a newly created Timer should not be a dangerous pattern.

@vtjnash
Copy link
Member

vtjnash commented Jun 17, 2024

Yes, that is what is wrong about this fix. The wait tries to do some fast paths before locking, but it doesn't implement those correctly, and it doesn't re-check if it is .set after !isopen

@A1-Mathematik
Copy link
Contributor

_trywait(t) || throw(EOFError())

Why is there an error throw anyways?

@lgeissbauer-btig
Copy link
Contributor

@vtjnash and @stevengj I went through the code a couple of times but don't feel confident to fix this. Can you help me a little to fix it proper

@lgeissbauer-btig
Copy link
Contributor

This should fix it #54955

@lgeissbauer-btig
Copy link
Contributor

This should be closed because #54955 is merge

@giordano giordano deleted the stevengj-patch-3 branch July 18, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants