Last active
April 12, 2020 17:25
-
-
Save jeffbass/fd86e149c4db10090dcc4b018500bcf1 to your computer and use it in GitHub Desktop.
An Imagehub code snippet for my PyCon 2020 presentation
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
#imagehub.py snippet | |
# (all the imports, logging setup hidden for now) | |
settings = Settings() # get settings from YAML file | |
hub = ImageHub(settings) # start ImageWriter, Timers, etc. | |
# forever event loop: receive & process images and text from imagenodes | |
while True: | |
try: | |
with Patience(hub.patience): | |
text, image = hub.receive_next() | |
except Patience.Timeout: # if no timely message from any node | |
hub.handle_timeout() | |
continue | |
reply = hub.process(text, image, settings) | |
hub.send_reply(reply) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment