| |
- __builtin__.object
-
- kevent
- kqueue
- exceptions.Exception(exceptions.BaseException)
-
- error
class kevent(__builtin__.object) |
|
kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)
This object is the equivalent of the struct kevent for the C API.
See the kqueue manpage for more detailed information about the meaning
of the arguments.
One minor note: while you might hope that udata could store a
reference to a python object, it cannot, because it is impossible to
keep a proper reference count of the object once it's passed into the
kernel. Therefore, I have restricted it to only storing an integer. I
recommend ignoring it and simply using the 'ident' field to key off
of. You could also set up a dictionary on the python side to store a
udata->object mapping. |
|
Methods defined here:
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __gt__(...)
- x.__gt__(y) <==> x>y
- __init__(...)
- x.__init__(...) initializes x; see help(type(x)) for signature
- __le__(...)
- x.__le__(y) <==> x<=y
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
Data descriptors defined here:
- data
- fflags
- filter
- flags
- ident
- udata
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class kqueue(__builtin__.object) |
|
Kqueue syscall wrapper.
For example, to start watching a socket for input:
>>> kq = kqueue()
>>> sock = socket()
>>> sock.connect((host, port))
>>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_ADD)], 0)
To wait one second for it to become writeable:
>>> kq.control(None, 1, 1000)
To stop listening:
>>> kq.control([kevent(sock, KQ_FILTER_WRITE, KQ_EV_DELETE)], 0) |
|
Methods defined here:
- close(...)
- close() -> None
Close the kqueue control file descriptor. Further operations on the kqueue
object will raise an exception.
- control(...)
- control(changelist, max_events[, timeout=None]) -> eventlist
Calls the kernel kevent function.
- changelist must be a list of kevent objects describing the changes
to be made to the kernel's watch list or None.
- max_events lets you specify the maximum number of events that the
kernel will return.
- timeout is the maximum time to wait in seconds, or else None,
to wait forever. timeout accepts floats for smaller timeouts, too.
- fileno(...)
- fileno() -> int
Return the kqueue control file descriptor.
- fromfd(...)
- fromfd(fd) -> kqueue
Create a kqueue object from a given control fd.
Data descriptors defined here:
- closed
- True if the kqueue handler is closed
Data and other attributes defined here:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
| |