Skip to content

Instantly share code, notes, and snippets.

@dsuch
Created May 13, 2014
Embed
What would you like to do?
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