MCPcopy Create free account
hub / github.com/StackStorm/st2 / run

Method run

contrib/examples/sensors/sample_sensor.py:35–50  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

33 pass
34
35 def run(self):
36 # This is where the crux of the sensor work goes.
37 # This is called once by the system.
38 # (If you want to sleep for regular intervals and keep
39 # interacting with your external system, you'd inherit from PollingSensor.)
40 # For example, let's consider a simple flask app. You'd run the flask app here.
41 # You can dispatch triggers using sensor_service like so:
42 # self.sensor_service(trigger, payload, trace_tag)
43 # # You can refer to the trigger as dict
44 # # { "name": ${trigger_name}, "pack": ${trigger_pack} }
45 # # or just simply by reference as string.
46 # # i.e. dispatch(${trigger_pack}.${trigger_name}, payload)
47 # # E.g.: dispatch('examples.foo_sensor', {'k1': 'stuff', 'k2': 'foo'})
48 # # trace_tag is a tag you would like to associate with the dispatched TriggerInstance
49 # # Typically the trace_tag is unique and a reference to an external event.
50 pass
51
52 def cleanup(self):
53 # This is called when the st2 system goes down. You can perform cleanup operations like

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected