mood.event — Python libev interface

loop([flags=EVFLAG_AUTO, callback=None, data=None, io_interval=0.0, timeout_interval=0.0])
Return type:Loop

This will instanciate the default loop if it hasn’t been created yet and return it. If the default loop was already initialized this simply returns it (and ignores the arguments).

The default loop is the only loop that can handle Child watchers, and to do this, it always registers a handler for SIGCHLD. If this is a problem for your application you can either instanciate a Loop which doesn’t do that, or you can simply overwrite the SIGCHLD signal handler.

See Loop for details about the arguments.

Note

If you don’t know what loop to use, use the one returned from this function.

supported_backends()
Return type:int

Returns the set of all backends compiled into this binary of libev (independent of their availability on the system you are running on).

recommended_backends()
Return type:int

Returns the set of all backends compiled into this binary of libev and also recommended for this platform, meaning it will work for most file descriptor types. This set is often smaller than the one returned by supported_backends(), as for example kqueue is broken on most BSDs and will not be auto-detected unless you explicitly request it. This is the set of backends that libev will probe for if you specify no backends explicitly.

embeddable_backends()
Return type:int

Returns the set of backends that are embeddable in other event loops. This value is platform-specific but can include backends not available on the current system. To find which embeddable backends might be supported on the current system, you would need to look at:

embeddable_backends() & supported_backends()

likewise for recommended ones:

embeddable_backends() & recommended_backends()

See Embed watchers for more information about embedding loops.

time()
Return type:float

Returns the current time as libev would use it.

Note

The now() method is usually faster and also often returns the timestamp you actually want to know.

sleep(interval)
Parameters:interval (float) – interval in seconds.

Sleep for the given interval. The current thread will be blocked until either it is interrupted or the given time interval has passed (approximately - it might return a bit earlier even if not interrupted). Returns immediately if interval <= 0.0.

Note

The range of interval is limited - libev only guarantees to work with sleep times of up to one day (interval <= 86400.0).

feed_signal(signum)
Parameters:signum (int) – signal number to feed libev.

This function can be used to “simulate” a signal receive. It is completely safe to call this function at any time, from any context, including signal handlers or random threads. Its main use is to customise signal handling in your process, especially in the presence of threads.

For example, using pthread_sigmask(), you could ignore signals by default in all threads (and specify EVFLAG_NOSIGMASK when creating any loops), and in one thread, wait for signals, then “deliver” them to libev by calling feed_signal().

@fatal

A callback using this decorator will stop the loop if an unhandled exception happens during its execution.

abi_version()
Return type:tuple(int, int)

Returns a tuple of major, minor version numbers. These numbers represent the libev ABI version that this module is running.

Note

This is not the same as libev version (although it might coincide).

__version__

mood.event’s version.

exception Error

Raised when an error specific to mood.event happens.