Skip to content

Instantly share code, notes, and snippets.

@dsuch
Created May 13, 2014 09:07
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 dsuch/214be28f1eaa8b964161 to your computer and use it in GitHub Desktop.
Save dsuch/214be28f1eaa8b964161 to your computer and use it in GitHub Desktop.
gevent-based service scheduling
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# gevent
from gevent import spawn_later
# Zato
from zato.server.service import Service
class MyTarget(Service):
name = 'my.target'
def handle(self):
self.logger.info('Target invoked with `%r`', self.request.raw_request)
class MyChannel(Service):
name = 'my.channel'
def schedule(self, name, sleep, *args, **kwargs):
spawn_later(sleep, self.invoke, name=name, *args, **kwargs)
def handle(self):
self.schedule('my.target', 60.0, payload='foo {}'.format(self.cid))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment