Skip to content

Instantly share code, notes, and snippets.

@jeffbass
Last active April 12, 2020 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbass/fd86e149c4db10090dcc4b018500bcf1 to your computer and use it in GitHub Desktop.
Save jeffbass/fd86e149c4db10090dcc4b018500bcf1 to your computer and use it in GitHub Desktop.
An Imagehub code snippet for my PyCon 2020 presentation
#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