-
-
Notifications
You must be signed in to change notification settings - Fork 430
Fix signal timer resetting #946
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -731,7 +731,6 @@ def cpu_signal_handler( | |
| to_wait = min(remaining_time, next_interval) | ||
| else: | ||
| to_wait = next_interval | ||
| Scalene.client_timer.reset() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works but I still get the warning about the signal, so we need to filter that.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is desired behavior-- we put in that warning because we're changing the behavior in a way transparent when you're doing Python-only stuff, but if someone was using a C extension module that raised
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I follow. This warning comes from when the signal is set in Python-land (in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right-- we print the warning because, while we can transparently redirect everything in Python-land, we want to warn the user in case they're doing something in C-land |
||
| Scalene.__signal_manager.restart_timer(to_wait) | ||
| else: | ||
| Scalene.__signal_manager.restart_timer(next_interval) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import signal | ||
|
|
||
| iterations = 10 | ||
|
|
||
| def my_handler(sig, frame): | ||
| global iterations | ||
| print(f"seconds remaining: {iterations}") | ||
| if iterations > 0: | ||
| iterations -= 1 | ||
| signal.setitimer(signal.ITIMER_REAL, 1.0, 0) | ||
|
|
||
| signal.signal(signal.SIGALRM, my_handler) | ||
| signal.setitimer(signal.ITIMER_REAL, 1.0, 0) | ||
|
|
||
| while iterations: | ||
| signal.pause() |
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.
This is a bad failure case, plus we have a regression test suite in
tests/. Make it a pytest and put it in that directory so it gets run in that workflow, but with a timeout for failure.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.
I think the failure case is the right one-- the behaviors this patch was in response to were the signal not being delivered for whatever reason and this test checks for progress.
I'll put it in the
testsworkflow, I actually think it makes sense as ataskwith a timeout rather than as a pytest though, unless you wanted to start making pytests that spawn new processes (which it doesn't seem like we do at the moment, the pytest suite seems to be mostly unit tests). I do think it's structurally more similar to the smoketests, since we're just checking "are the signals delivered and does it create a profile with any data in it", but that's your callThere 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.
I mean that the CI will get hung up - no idea what the timeout is for that thing - so the latter suggestion works.
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.
The timeout of the CI is 15 minutes and I put in a timeout of 30 seconds for the task I created, where would the hangup happen?
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.
Also the smoketests worked fine, I could make sure the timeout works as expected but I trust the
timeout-minutesdirective to do the right thing