pyev — Python libev interface.

Platforms: POSIX, Windows

pyev.default_loop([flags=EVFLAG_AUTO, callback=None, data=None, debug=False, io_interval=0.0, timeout_interval=0.0]) → the 'default 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.

pyev.supported_backends() → int

Returns the set of all backends (i.e. their corresponding EVBACKEND_* value) compiled into this binary of libev (independent of their availability on the system you are running on).

See backends for a description of the set values.

pyev.recommended_backends() → 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 you if you specify no backends explicitly.

See backends for a description of the set values.

pyev.embeddable_backends() → 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:

pyev.embeddable_backends() & pyev.supported_backends()

likewise for recommended ones:

pyev.embeddable_backends() & pyev.recommended_backends()

See backends for a description of the set values.

pyev.time() → float

Returns the current time as libev would use it.

Note

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

pyev.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.

pyev.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 the signal module, 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().

pyev.abi_version() → tuple of ints

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).

pyev.version() → tuple of strings

Returns a tuple of version strings. The former is pyev version, while the latter is the underlying libev version.

exception pyev.Error

Raised when an error specific to pyev happens.

Table Of Contents

Previous topic

Welcome to pyev’s documentation!

Next topic

Loop — Event loop

This Page