From 3cf53667c8e2c5b4fe5a87ae7a3624aba0139590 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 6 Oct 2015 13:50:29 +0800 Subject: [PATCH] examples: add RunForever experiment to demonstrate graceful termination --- examples/master/repository/run_forever.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/master/repository/run_forever.py diff --git a/examples/master/repository/run_forever.py b/examples/master/repository/run_forever.py new file mode 100644 index 000000000..73f6e2e20 --- /dev/null +++ b/examples/master/repository/run_forever.py @@ -0,0 +1,18 @@ +from itertools import count +from time import sleep + +from artiq import * + + +class RunForever(EnvExperiment): + def build(self): + self.setattr_device("scheduler") + + def run(self): + try: + for i in count(): + self.scheduler.pause() + sleep(1) + print("ping", i) + except TerminationRequested: + print("Terminated gracefully")