Skip to content

Commit 30df5e6

Browse files
authored
Fixed issue where signal timer not resetting properly (#946)
1 parent 8915c3e commit 30df5e6

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/test-smoketests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ jobs:
5151
- name: decorator smoke test
5252
run: python test/smoketest_profile_decorator.py
5353

54+
# NOTE: this is a regression test for signals not being
55+
# restarted properly. It checks whether the program
56+
# halts or runs forever, not for correctness of timing.
57+
- name: signal smoketest
58+
run: python test/smoketest.py test/signal_test.py
59+
timeout-minutes: 0.5
5460
# FIXME: these tests are broken under the current Github runner
5561
#
5662
# - name: line invalidation test

scalene/scalene_profiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,6 @@ def cpu_signal_handler(
731731
to_wait = min(remaining_time, next_interval)
732732
else:
733733
to_wait = next_interval
734-
Scalene.client_timer.reset()
735734
Scalene.__signal_manager.restart_timer(to_wait)
736735
else:
737736
Scalene.__signal_manager.restart_timer(next_interval)

test/signal_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import signal
2+
3+
iterations = 10
4+
5+
def my_handler(sig, frame):
6+
global iterations
7+
print(f"seconds remaining: {iterations}")
8+
if iterations > 0:
9+
iterations -= 1
10+
signal.setitimer(signal.ITIMER_REAL, 1.0, 0)
11+
12+
signal.signal(signal.SIGALRM, my_handler)
13+
signal.setitimer(signal.ITIMER_REAL, 1.0, 0)
14+
15+
while iterations:
16+
signal.pause()

0 commit comments

Comments
 (0)