pause and reschedule the current greenlet and switch to the next
Note
this method blocks for a short period of time
pause and reschedule the current greenlet until a set time
Note
this method will block the current greenlet
Parameters: | unixtime (int or float) – the unix timestamp of when to bring this greenlet back |
---|
pause and reschedule the current greenlet for a set number of seconds
Note
this method will block the current greenlet
Parameters: | secs (int or float) – number of seconds to pause |
---|
insert a greenlet into the scheduler
If provided a function, it is wrapped in a new greenlet
Parameters: |
|
---|---|
Returns: | the target argument |
This function can also be used as a decorator, either preloading args and/or kwargs or not:
>>> @schedule
>>> def f():
... print 'hello from f'
>>> @schedule(args=('world',))
>>> def f(name):
... print 'hello %s' % name
insert a greenlet into the scheduler to be run at a set time
If provided a function, it is wrapped in a new greenlet
Parameters: |
|
---|---|
Returns: | the target argument |
This function can also be used as a decorator:
>>> @schedule_at(1296423834)
>>> def f():
... print 'hello from f'
and args/kwargs can also be preloaded:
>>> @schedule_at(1296423834, args=('world',))
>>> def f(name):
... print 'hello %s' % name
insert a greenlet into the scheduler to run after a set time
If provided a function, it is wrapped in a new greenlet
Parameters: |
|
---|---|
Returns: | the target argument |
This function can also be used as a decorator:
>>> @schedule_in(30)
>>> def f():
... print 'hello from f'
and args/kwargs can also be preloaded:
>>> @schedule_in(30, args=('world',))
>>> def f(name):
... print 'hello %s' % name
insert a greenlet into the scheduler to run regularly at an interval
If provided a function, it is wrapped in a new greenlet
Parameters: |
|
---|---|
Returns: | the target argument |
This function can also be used as a decorator:
>>> @schedule_recurring(30)
>>> def f():
... print "the regular 'hello' from f"
and args/kwargs can also be preloaded:
>>> @schedule_recurring(30, args=('world',))
>>> def f(name):
... print 'the regular hello %s' % name
schedule a greenlet to have an exception raised in it immediately
Parameters: |
|
---|
schedule a greenlet to have an exception raised at a unix timestamp
Parameters: |
|
---|
schedule a greenlet receive an exception after a number of seconds
Parameters: |
|
---|
schedule a greenlet to be stopped immediately
Parameters: | target (greenlet) – the greenlet to end |
---|
add a callback for when an exception goes uncaught in any greenlet
Parameters: | handler (function) – the callback function. must be a function taking 3 arguments:
|
---|
Note also that the callback is only held by a weakref, so if all other refs to the function are lost it will stop handling greenlets’ exceptions
remove a callback from the list of global exception handlers
Parameters: | handler (function) – the callback, previously added via global_exception_handler(), to remove |
---|---|
Returns: | bool, whether the handler was found (and therefore removed) |
add a callback for when an exception occurs in a particular greenlet
Parameters: |
|
---|
remove a callback from the list of exception handlers for a coroutine
Parameters: |
|
---|---|
Returns: | bool, whether the handler was found (and therefore removed) |
run all the registered exception handlers
the first 3 arguments to this function match the output of sys.exc_info()
Parameters: |
|
---|
exception handlers run would be all those added with global_exception_handler(), and any added for the relevant coroutine with local_exception_handler().
create a new greenlet from a function and arguments
Parameters: |
|
---|
the only major difference between this function and that of the basic greenlet api is that this one sets the new greenlet’s parent to be the greenhouse main loop greenlet, which is a requirement for greenlets that will wind up in the greenhouse scheduler.
add a callback to run in every switch between coroutines
Parameters: | handler (function) – the callback function, must be a function taking 2 arguments:
be aware that only a weak reference to this function will be held. |
---|
remove a callback from the list of global hooks
Parameters: | handler (function) – the callback function, previously added with global_hook, to remove from the list of global hooks |
---|---|
Returns: | bool, whether the handler was removed from the global hooks |
add a callback to run every time a greenlet is about to be switched to
Parameters: |
|
---|
remove a callback from the incoming hooks for a particular coro
Parameters: |
|
---|---|
Returns: | bool, whether the handler was found and removed |
add a callback to run every time a greenlet is switched away from
Parameters: |
|
---|
remove a callback from the outgoing hooks for a particular coro
Parameters: |
|
---|---|
Returns: | bool, whether the handler was found and removed |
turn off EINTR-raising from emulated syscalls on interruption by signals
due to the nature of greenhouse’s system call emulation, signal.siginterrupt can’t be made to work with it. specifically, greenhouse can’t differentiate between different signals. so this function toggles whether to restart for ALL or NO signals.
Parameters: | flag (bool) – whether to turn EINTR exceptions off (True) or on (False) |
---|
replace the scheduler’s poller, throwing away any pre-existing state
this is only really a good idea in the new child process after a fork(2).