Last active
March 24, 2020 14:04
-
-
Save daykin/8313007c642cb4959b8c59d4d6b73cf3 to your computer and use it in GitHub Desktop.
camonitor callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pkg_resources import require | |
require('cothread') | |
import cothread | |
from cothread import Timedout | |
from cothread.catools import caput, camonitor | |
done = cothread.Event() | |
def callback(value): | |
if value == "whatever value I'm looking for": | |
done.Signal() | |
monitor = camonitor("foo", callback, datatype=DBR_STRING) | |
caput("foo", "whatever value I'm looking for") | |
try: | |
done.Wait(timeout=42) | |
print("success") | |
except Timedout: | |
print("failed") | |
monitor.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment