hephy-dd / comet

COMET - Control and Measurement Toolkit
GNU General Public License v3.0
2 stars 2 forks source link

Improved process callbacks #33

Closed arnobaer closed 4 years ago

arnobaer commented 4 years ago

An optimized approach for custom process/thread callback registration and calls.

class Process(comet.Process):
    def run(self):
        while self.running:
            self.push("temp", 22.5)
            self.push("humid", 50.0)
            self.push("status", 42)

process = Process(
    fail=ctrl.handle_error, # built in callback
    temp=ctrl.handle_temp,
    humid=ctrl.handle_humid
)
process.callbacks["status"] = ctrl.handle_status
...

Optional move built in callbacks begin, finish and fail also to property callbacks to avoid accidental assignment in process run().