Example #1
0
def timer(loop, delay, times, handler, arg):
    """
    Register a timer that expires after some delay and repeats some number of
    times. At each expiry, will call the handler, passing the arg. To
    run a timer forever, use 0 times. Returns a timer_id or -1 if there was an
    error.
    """
    return C.zloop_timer(loop, delay, times, handler, ffi.new_handle(arg))
Example #2
0
def timer(loop, delay, times, handler, arg):
    """
    Register a timer that expires after some delay and repeats some number of
    times. At each expiry, will call the handler, passing the arg. To
    run a timer forever, use 0 times. Returns a timer_id or -1 if there was an
    error.
    """
    return C.zloop_timer(loop, delay, times, handler, ffi.new_handle(arg))
Example #3
0
def poller(p, item, handler, arg=None):
    """
    Register pollitem with the reactor. When the pollitem is ready, will call
    the handler, passing the arg. Returns 0 if OK, -1 if there was an error.
    If you register the pollitem more than once, each instance will invoke its
    corresponding handler.

    """
    return C.zloop_poller(p, item, handler, ffi.new_handle(arg))
Example #4
0
def poller(p, item, handler, arg=None):
    """
    Register pollitem with the reactor. When the pollitem is ready, will call
    the handler, passing the arg. Returns 0 if OK, -1 if there was an error.
    If you register the pollitem more than once, each instance will invoke its
    corresponding handler.

    """
    return C.zloop_poller(p, item, handler, ffi.new_handle(arg))
Example #5
0
def new(task, args):
    """Create a new actor passing arbitrary arguments reference."""
    return ffi.gc(C.zactor_new(task, ffi.new_handle(args)), destroy)
Example #6
0
 def timer_end(self, arg):
     arg_handle = ffi.new_handle(arg)
     zloop.timer_end(self.loop, arg_handle)
Example #7
0
 def timer(self, delay, times, handler, arg=None):
     callback = ffi.callback('zloop_fn', handler)
     arg_handle = ffi.new_handle(arg)
     return zloop.timer(self.loop, delay, times, callback, arg_handle)
Example #8
0
 def poller(self, poll_item, handler, arg=None):
     callback = ffi.callback('zloop_fn', handler)
     arg_handle = ffi.new_handle(arg)
     return zloop.poller(self.loop, poll_item, callback, arg_handle)
Example #9
0
def reader(loop, sock, handler, arg):
    """Register socket reader with the reactor. When the reader has messages,
    the reactor will call the handler, passing the arg. Returns 0 if OK, -1
    if there was an error. If you register the same socket more than once,
    each instance will invoke its corresponding handler."""
    return C.zloop_reader(loop, sock, handler, ffi.new_handle(arg))