diff options
author | rcoh <rcoh@mit.edu> | 2011-02-01 23:14:12 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2011-02-01 23:14:12 -0500 |
commit | 5a97e7548b0ec44f0d61a724903748197e69df7c (patch) | |
tree | 7bb6b8ea7e488949eeb16ae18b0ad2230f1f7c9b /behaviors/Timeout.py | |
parent | 082e4b0c53123dd377da148541f7d98516716862 (diff) | |
parent | 482a94fd48627153b923931d6ff21ebf57fad6f7 (diff) |
Merge branch 'osc' of github.com:rcoh/SmootLight into osc
Diffstat (limited to 'behaviors/Timeout.py')
-rw-r--r-- | behaviors/Timeout.py | 16 |
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,[]) |