GodsDevProject commited on
Commit
a66b3e8
·
verified ·
1 Parent(s): 8aeaa64

Create policy/kill_switch.py

Browse files
Files changed (1) hide show
  1. policy/kill_switch.py +3 -20
policy/kill_switch.py CHANGED
@@ -1,26 +1,9 @@
1
- import time
2
-
3
  class KillSwitch:
4
  def __init__(self):
5
  self.disabled = {}
6
- self.cooldown = 3600 # 1 hour
7
 
8
  def disable(self, agency, reason):
9
- self.disabled[agency] = {
10
- "reason": reason,
11
- "time": time.time()
12
- }
13
-
14
- def is_enabled(self, agency):
15
- if agency not in self.disabled:
16
- return True
17
-
18
- elapsed = time.time() - self.disabled[agency]["time"]
19
- if elapsed > self.cooldown:
20
- del self.disabled[agency]
21
- return True
22
-
23
- return False
24
 
25
- def reason(self, agency):
26
- return self.disabled.get(agency, {}).get("reason", "")
 
 
 
1
  class KillSwitch:
2
  def __init__(self):
3
  self.disabled = {}
 
4
 
5
  def disable(self, agency, reason):
6
+ self.disabled[agency] = reason
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ def enabled(self, agency):
9
+ return agency not in self.disabled