Skip to content

Instantly share code, notes, and snippets.

@asterite3
Created April 11, 2017 23:07
Show Gist options
  • Save asterite3/4e5a2bafdfbea504454b2c1388e93559 to your computer and use it in GitHub Desktop.
Save asterite3/4e5a2bafdfbea504454b2c1388e93559 to your computer and use it in GitHub Desktop.
import circus
from circus import get_arbiter
from tornado import gen
task = {
"cmd": "ls",
"args": ["/tmp/test-mount/"]
}
arbiter = get_arbiter(watchers=[task], debug=True)
@gen.coroutine
def stop_arbiter_after_timeout():
print 'sleeping'
yield gen.sleep(5)
print 'stopping arbiter'
yield arbiter.stop()
print 'stopped'
def start_arbiter(*args, **kwargs):
print 'start arbiter'
arbiter.start(cb=kwargs['callback'])
@gen.coroutine
def run():
yield [stop_arbiter_after_timeout(), gen.Task(start_arbiter)]
run()
print 'done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment