Random utilities

gevent.select module

gevent.select.select(rlist, wlist, xlist, timeout=None)

An implementation of select.select() that blocks only the current greenlet.

Note: xlist is ignored.

Python helpers (gevent.util module)

class gevent.util.wrap_errors(errors, func)

Helper to make function return an exception, rather than raise it.

Because every exception that is unhandled by greenlet will be logged, it is desirable to prevent non-error exceptions from leaving a greenlet. This can done with simple try/except construct:

def wrapped_func(*args, **kwargs):
    try:
        return func(*args, **kwargs)
    except (A, B, C), ex:
        return ex

wrap_errors provides a shortcut to write that in one line:

wrapped_func = wrap_errors((A, B, C), func)

It also preserves __str__ and __repr__ of the original function.

gevent.util.lazy_property
A decorator similar to property() that only calls the function once.

Table Of Contents

Previous topic

Managing greenlets in a group

Next topic

Synchronous wrappers around libevent-dns

This Page