-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
30 lines (26 loc) · 743 Bytes
/
utils.py
File metadata and controls
30 lines (26 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time
import signal
class OnTime():
def __init__(self, interval):
self.interval = interval
self.last_run = None
def __call__(self):
now = time.time()
if self.last_run is None:
self.last_run = now
if now - self.last_run > self.interval:
self.last_run = now
return True
return False
class Breakpoint():
def __init__(self):
import signal
self.break_point = False
def handler(signum, frame):
self.break_point = True
signal.signal(signal.SIGQUIT, handler)
def __call__(self):
if self.break_point:
import pdb
self.break_point = False
pdb.set_trace()