pyuv.util — Miscelaneous utilities

pyuv.util.hrtime()

Get the high-resolution system time. It’s given in nanoseconds, even if the system doesn’t support nanosecond precision.

pyuv.util.get_free_memory()

Get the system free memory (in bytes).

pyuv.util.get_total_memory()

Get the system total memory (in bytes).

pyuv.util.loadavg()

Get the system load average.

pyuv.util.uptime()

Get the current uptime.

pyuv.util.resident_set_size()

Get the current resident memory size.

pyuv.util.interface_addresses()

Get interface addresses information.

pyuv.util.cpu_info()

Get CPUs information.

pyuv.util.getaddrinfo(...)

Asyncronous equivalent of socket.getaddrinfo. This function returns a GAIRequest object which has a cancel() method that can be called in order to cancel the request.

class pyuv.util.SignalChecker(loop, fd)
Parameters:
  • loop (Loop) – loop object where this handle runs (accessible through SignalChecker.loop).
  • fd (int) – File descriptor to be monitored for readability.

SignalChecker is a handle which can be used to interact with signals set up by the standard signal module.

Here is how it works: the user is required to get a pair of file descriptors and put them in nonblocking mode. These descriptors can be either a os.pipe(), a socket.socketpair() or a manually made pair of connected sockets. One of these descriptors will be used just for writing, and the other end for reading. The user must use signal.set_wakeup_fd and register the write descriptor. The read descriptor must be passed to this handle. When the process receives a signal Python will write on the write end of the socket pair and it will cause the SignalChecker to wakeup the loop and call the Python C API function to process signals: PyErr_CheckSignals.

It’s better to use the Signal handle also provided by this library, because it doesn’t need any work from the user and it works on any thread. This handle merely exists for some cases which you don’t probably care about, or if you want to use the signal module directly.

start()

Start the signal checking handle.

stop()

Stop the signal checking handle.

Previous topic

pyuv.thread — Thread synchronization primitives

Next topic

Reference counting scheme

This Page