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

Method poll

contrib/examples/sensors/fibonacci_sensor.py:38–61  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

36 self.logger = self.sensor_service.get_logger(name=self.__class__.__name__)
37
38 def poll(self):
39 # Reset a and b if there are large enough to avoid integer overflow problems
40 if self.a > 10000 or self.b > 10000:
41 self.logger.debug("Reseting values to avoid integer overflow issues")
42
43 self.a = 0
44 self.b = 1
45 self.count = 2
46
47 fib = self.a + self.b
48 self.logger.debug(
49 "Count: %d, a: %d, b: %d, fib: %s", self.count, self.a, self.b, fib
50 )
51
52 payload = {
53 "count": self.count,
54 "fibonacci": fib,
55 "pythonpath": os.environ.get("PYTHONPATH", None),
56 }
57
58 self.sensor_service.dispatch(trigger="examples.fibonacci", payload=payload)
59 self.a = self.b
60 self.b = fib
61 self.count = self.count + 1
62
63 def cleanup(self):
64 pass

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected