<s> from calvin . actor . actor import Actor , ActionResult , manage , condition , guard <EOL> class ClassicDelay ( Actor ) : <EOL> """<STR_LIT>""" <EOL> @ manage ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def init ( self , delay = <NUM_LIT:0.1> ) : <EOL> self . delay = delay <EOL> self . timer = None <EOL> self . started = False <EOL> self . setup ( ) <EOL> def setup ( self ) : <EOL> self . use ( '<STR_LIT>' , shorthand = '<STR_LIT>' ) <EOL> def start ( self ) : <EOL> self . timer = self [ '<STR_LIT>' ] . repeat ( self . delay ) <EOL> self . started = True <EOL> def will_migrate ( self ) : <EOL> if self . timer : <EOL> self . timer . cancel ( ) <EOL> def did_migrate ( self ) : <EOL> self . setup ( ) <EOL> if self . started : <EOL> self . start ( ) <EOL> @ condition ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> @ guard ( lambda self , _ : not self . started ) <EOL> def start_timer ( self , token ) : <EOL> self . start ( ) <EOL> return ActionResult ( production = ( token , ) ) <EOL> @ condition ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> @ guard ( lambda self , _ : self . timer and self . timer . triggered ) <EOL> def passthrough ( self , token ) : <EOL> self . timer . ack ( ) <EOL> return ActionResult ( production = ( token , ) ) <EOL> action_priority = ( start_timer , passthrough ) <EOL> requires = [ '<STR_LIT>' ] </s>
