aboutsummaryrefslogtreecommitdiff
path: root/behaviors/Timeout.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-01-27 16:50:59 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-01-27 16:50:59 -0500
commit5fb3ea060025241105dc8e9a174513c112f9a133 (patch)
treee98b1b3eab0b05b0e518b08cbab086d224fd9250 /behaviors/Timeout.py
parent5d29906fff79bc6e4ba83be7028e1380a0014d21 (diff)
A metric $#%$-ton of changes. Added doc-strings to EVERYTHING. Phew. Fixed a massive bug that
increases performance in by up to a factor of 60. A bunch of new behaviors for the class.
Diffstat (limited to 'behaviors/Timeout.py')
-rw-r--r--behaviors/Timeout.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/behaviors/Timeout.py b/behaviors/Timeout.py
new file mode 100644
index 0000000..14d4873
--- /dev/null
+++ b/behaviors/Timeout.py
@@ -0,0 +1,16 @@
+from operationscore.Behavior import *
+import util.TimeOps as timeops
+class Timeout(Behavior):
+ """Timeout is a behavior designed to be used in recursive hooks to stop responses after a certain
+ amount of time. It is the Time-version of RecursiveDecay. Specify:
+ <TimeOut> -- the time in ms that the response will run.
+ """
+
+ def processResponse(self,sensorInputs, recur):
+ ret = []
+ for data in sensorInputs:
+ if not 'StartTime' in data:
+ data['StartTime'] = timeops.time()
+ if timeops.time()-data['StartTime'] < self['Timeout']:
+ ret.append(data)
+ return (ret,[])