File: signal_ignorer.py

package info (click to toggle)
con-duct 0.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 584 kB
  • sloc: python: 4,324; sh: 22; makefile: 18
file content (19 lines) | stat: -rwxr-xr-x 486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3
import signal
import time
from types import FrameType
from typing import Optional


def handle_signal(sig: int, _frame: Optional[FrameType]) -> None:
    print(f"Received {sig}")


if __name__ == "__main__":
    signal.signal(signal.SIGINT, handle_signal)
    signal.siginterrupt(
        signal.SIGINT, False
    )  # Restart interrupted system calls so we can test multiple SIGINTS
    t0 = time.time()
    while time.time() - t0 < 10:
        time.sleep(0.01)