1:mod:`select` --- Waiting for I/O completion
2============================================
3
4.. module:: select
5   :synopsis: Wait for I/O completion on multiple streams.
6
7--------------
8
9This module provides access to the :c:func:`select` and :c:func:`poll` functions
10available in most operating systems, :c:func:`devpoll` available on
11Solaris and derivatives, :c:func:`epoll` available on Linux 2.5+ and
12:c:func:`kqueue` available on most BSD.
13Note that on Windows, it only works for sockets; on other operating systems,
14it also works for other file types (in particular, on Unix, it works on pipes).
15It cannot be used on regular files to determine whether a file has grown since
16it was last read.
17
18.. note::
19
20   The :mod:`selectors` module allows high-level and efficient I/O
21   multiplexing, built upon the :mod:`select` module primitives. Users are
22   encouraged to use the :mod:`selectors` module instead, unless they want
23   precise control over the OS-level primitives used.
24
25
26The module defines the following:
27
28
29.. exception:: error
30
31   A deprecated alias of :exc:`OSError`.
32
33   .. versionchanged:: 3.3
34      Following :pep:`3151`, this class was made an alias of :exc:`OSError`.
35
36
37.. function:: devpoll()
38
39   (Only supported on Solaris and derivatives.)  Returns a ``/dev/poll``
40   polling object; see section :ref:`devpoll-objects` below for the
41   methods supported by devpoll objects.
42
43   :c:func:`devpoll` objects are linked to the number of file
44   descriptors allowed at the time of instantiation. If your program
45   reduces this value, :c:func:`devpoll` will fail. If your program
46   increases this value, :c:func:`devpoll` may return an
47   incomplete list of active file descriptors.
48
49   The new file descriptor is :ref:`non-inheritable <fd_inheritance>`.
50
51   .. versionadded:: 3.3
52
53   .. versionchanged:: 3.4
54      The new file descriptor is now non-inheritable.
55
56.. function:: epoll(sizehint=-1, flags=0)
57
58   (Only supported on Linux 2.5.44 and newer.) Return an edge polling object,
59   which can be used as Edge or Level Triggered interface for I/O
60   events.
61
62   *sizehint* informs epoll about the expected number of events to be
63   registered.  It must be positive, or `-1` to use the default. It is only
64   used on older systems where :c:func:`epoll_create1` is not available;
65   otherwise it has no effect (though its value is still checked).
66
67   *flags* is deprecated and completely ignored.  However, when supplied, its
68   value must be ``0`` or ``select.EPOLL_CLOEXEC``, otherwise ``OSError`` is
69   raised.
70
71   See the :ref:`epoll-objects` section below for the methods supported by
72   epolling objects.
73
74   ``epoll`` objects support the context management protocol: when used in a
75   :keyword:`with` statement, the new file descriptor is automatically closed
76   at the end of the block.
77
78   The new file descriptor is :ref:`non-inheritable <fd_inheritance>`.
79
80   .. versionchanged:: 3.3
81      Added the *flags* parameter.
82
83   .. versionchanged:: 3.4
84      Support for the :keyword:`with` statement was added.
85      The new file descriptor is now non-inheritable.
86
87   .. deprecated:: 3.4
88      The *flags* parameter.  ``select.EPOLL_CLOEXEC`` is used by default now.
89      Use :func:`os.set_inheritable` to make the file descriptor inheritable.
90
91
92.. function:: poll()
93
94   (Not supported by all operating systems.)  Returns a polling object, which
95   supports registering and unregistering file descriptors, and then polling them
96   for I/O events; see section :ref:`poll-objects` below for the methods supported
97   by polling objects.
98
99
100.. function:: kqueue()
101
102   (Only supported on BSD.)  Returns a kernel queue object; see section
103   :ref:`kqueue-objects` below for the methods supported by kqueue objects.
104
105   The new file descriptor is :ref:`non-inheritable <fd_inheritance>`.
106
107   .. versionchanged:: 3.4
108      The new file descriptor is now non-inheritable.
109
110
111.. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)
112
113   (Only supported on BSD.)  Returns a kernel event object; see section
114   :ref:`kevent-objects` below for the methods supported by kevent objects.
115
116
117.. function:: select(rlist, wlist, xlist[, timeout])
118
119   This is a straightforward interface to the Unix :c:func:`select` system call.
120   The first three arguments are sequences of 'waitable objects': either
121   integers representing file descriptors or objects with a parameterless method
122   named :meth:`~io.IOBase.fileno` returning such an integer:
123
124   * *rlist*: wait until ready for reading
125   * *wlist*: wait until ready for writing
126   * *xlist*: wait for an "exceptional condition" (see the manual page for what
127     your system considers such a condition)
128
129   Empty sequences are allowed, but acceptance of three empty sequences is
130   platform-dependent. (It is known to work on Unix but not on Windows.)  The
131   optional *timeout* argument specifies a time-out as a floating point number
132   in seconds.  When the *timeout* argument is omitted the function blocks until
133   at least one file descriptor is ready.  A time-out value of zero specifies a
134   poll and never blocks.
135
136   The return value is a triple of lists of objects that are ready: subsets of the
137   first three arguments.  When the time-out is reached without a file descriptor
138   becoming ready, three empty lists are returned.
139
140   .. index::
141      single: socket() (in module socket)
142      single: popen() (in module os)
143
144   Among the acceptable object types in the sequences are Python :term:`file
145   objects <file object>` (e.g. ``sys.stdin``, or objects returned by
146   :func:`open` or :func:`os.popen`), socket objects returned by
147   :func:`socket.socket`.  You may also define a :dfn:`wrapper` class yourself,
148   as long as it has an appropriate :meth:`~io.IOBase.fileno` method (that
149   really returns a file descriptor, not just a random integer).
150
151   .. note::
152
153      .. index:: single: WinSock
154
155      File objects on Windows are not acceptable, but sockets are.  On Windows,
156      the underlying :c:func:`select` function is provided by the WinSock
157      library, and does not handle file descriptors that don't originate from
158      WinSock.
159
160   .. versionchanged:: 3.5
161      The function is now retried with a recomputed timeout when interrupted by
162      a signal, except if the signal handler raises an exception (see
163      :pep:`475` for the rationale), instead of raising
164      :exc:`InterruptedError`.
165
166
167.. attribute:: PIPE_BUF
168
169   The minimum number of bytes which can be written without blocking to a pipe
170   when the pipe has been reported as ready for writing by :func:`~select.select`,
171   :func:`poll` or another interface in this module.  This doesn't apply
172   to other kind of file-like objects such as sockets.
173
174   This value is guaranteed by POSIX to be at least 512.
175
176   .. availability:: Unix
177
178   .. versionadded:: 3.2
179
180
181.. _devpoll-objects:
182
183``/dev/poll`` Polling Objects
184-----------------------------
185
186Solaris and derivatives have ``/dev/poll``. While :c:func:`select` is
187O(highest file descriptor) and :c:func:`poll` is O(number of file
188descriptors), ``/dev/poll`` is O(active file descriptors).
189
190``/dev/poll`` behaviour is very close to the standard :c:func:`poll`
191object.
192
193
194.. method:: devpoll.close()
195
196   Close the file descriptor of the polling object.
197
198   .. versionadded:: 3.4
199
200
201.. attribute:: devpoll.closed
202
203   ``True`` if the polling object is closed.
204
205   .. versionadded:: 3.4
206
207
208.. method:: devpoll.fileno()
209
210   Return the file descriptor number of the polling object.
211
212   .. versionadded:: 3.4
213
214
215.. method:: devpoll.register(fd[, eventmask])
216
217   Register a file descriptor with the polling object.  Future calls to the
218   :meth:`poll` method will then check whether the file descriptor has any
219   pending I/O events.  *fd* can be either an integer, or an object with a
220   :meth:`~io.IOBase.fileno` method that returns an integer.  File objects
221   implement :meth:`!fileno`, so they can also be used as the argument.
222
223   *eventmask* is an optional bitmask describing the type of events you want to
224   check for. The constants are the same that with :c:func:`poll`
225   object. The default value is a combination of the constants :const:`POLLIN`,
226   :const:`POLLPRI`, and :const:`POLLOUT`.
227
228   .. warning::
229
230      Registering a file descriptor that's already registered is not an
231      error, but the result is undefined. The appropriate action is to
232      unregister or modify it first. This is an important difference
233      compared with :c:func:`poll`.
234
235
236.. method:: devpoll.modify(fd[, eventmask])
237
238   This method does an :meth:`unregister` followed by a
239   :meth:`register`. It is (a bit) more efficient that doing the same
240   explicitly.
241
242
243.. method:: devpoll.unregister(fd)
244
245   Remove a file descriptor being tracked by a polling object.  Just like the
246   :meth:`register` method, *fd* can be an integer or an object with a
247   :meth:`~io.IOBase.fileno` method that returns an integer.
248
249   Attempting to remove a file descriptor that was never registered is
250   safely ignored.
251
252
253.. method:: devpoll.poll([timeout])
254
255   Polls the set of registered file descriptors, and returns a possibly-empty list
256   containing ``(fd, event)`` 2-tuples for the descriptors that have events or
257   errors to report. *fd* is the file descriptor, and *event* is a bitmask with
258   bits set for the reported events for that descriptor --- :const:`POLLIN` for
259   waiting input, :const:`POLLOUT` to indicate that the descriptor can be written
260   to, and so forth. An empty list indicates that the call timed out and no file
261   descriptors had any events to report. If *timeout* is given, it specifies the
262   length of time in milliseconds which the system will wait for events before
263   returning. If *timeout* is omitted, -1, or :const:`None`, the call will
264   block until there is an event for this poll object.
265
266   .. versionchanged:: 3.5
267      The function is now retried with a recomputed timeout when interrupted by
268      a signal, except if the signal handler raises an exception (see
269      :pep:`475` for the rationale), instead of raising
270      :exc:`InterruptedError`.
271
272
273.. _epoll-objects:
274
275Edge and Level Trigger Polling (epoll) Objects
276----------------------------------------------
277
278   https://linux.die.net/man/4/epoll
279
280   *eventmask*
281
282   +-------------------------+-----------------------------------------------+
283   | Constant                | Meaning                                       |
284   +=========================+===============================================+
285   | :const:`EPOLLIN`        | Available for read                            |
286   +-------------------------+-----------------------------------------------+
287   | :const:`EPOLLOUT`       | Available for write                           |
288   +-------------------------+-----------------------------------------------+
289   | :const:`EPOLLPRI`       | Urgent data for read                          |
290   +-------------------------+-----------------------------------------------+
291   | :const:`EPOLLERR`       | Error condition happened on the assoc. fd     |
292   +-------------------------+-----------------------------------------------+
293   | :const:`EPOLLHUP`       | Hang up happened on the assoc. fd             |
294   +-------------------------+-----------------------------------------------+
295   | :const:`EPOLLET`        | Set Edge Trigger behavior, the default is     |
296   |                         | Level Trigger behavior                        |
297   +-------------------------+-----------------------------------------------+
298   | :const:`EPOLLONESHOT`   | Set one-shot behavior. After one event is     |
299   |                         | pulled out, the fd is internally disabled     |
300   +-------------------------+-----------------------------------------------+
301   | :const:`EPOLLEXCLUSIVE` | Wake only one epoll object when the           |
302   |                         | associated fd has an event. The default (if   |
303   |                         | this flag is not set) is to wake all epoll    |
304   |                         | objects polling on a fd.                      |
305   +-------------------------+-----------------------------------------------+
306   | :const:`EPOLLRDHUP`     | Stream socket peer closed connection or shut  |
307   |                         | down writing half of connection.              |
308   +-------------------------+-----------------------------------------------+
309   | :const:`EPOLLRDNORM`    | Equivalent to :const:`EPOLLIN`                |
310   +-------------------------+-----------------------------------------------+
311   | :const:`EPOLLRDBAND`    | Priority data band can be read.               |
312   +-------------------------+-----------------------------------------------+
313   | :const:`EPOLLWRNORM`    | Equivalent to :const:`EPOLLOUT`               |
314   +-------------------------+-----------------------------------------------+
315   | :const:`EPOLLWRBAND`    | Priority data may be written.                 |
316   +-------------------------+-----------------------------------------------+
317   | :const:`EPOLLMSG`       | Ignored.                                      |
318   +-------------------------+-----------------------------------------------+
319
320   .. versionadded:: 3.6
321      :const:`EPOLLEXCLUSIVE` was added.  It's only supported by Linux Kernel 4.5
322      or later.
323
324.. method:: epoll.close()
325
326   Close the control file descriptor of the epoll object.
327
328
329.. attribute:: epoll.closed
330
331   ``True`` if the epoll object is closed.
332
333
334.. method:: epoll.fileno()
335
336   Return the file descriptor number of the control fd.
337
338
339.. method:: epoll.fromfd(fd)
340
341   Create an epoll object from a given file descriptor.
342
343
344.. method:: epoll.register(fd[, eventmask])
345
346   Register a fd descriptor with the epoll object.
347
348
349.. method:: epoll.modify(fd, eventmask)
350
351   Modify a registered file descriptor.
352
353
354.. method:: epoll.unregister(fd)
355
356   Remove a registered file descriptor from the epoll object.
357
358
359.. method:: epoll.poll(timeout=-1, maxevents=-1)
360
361   Wait for events. timeout in seconds (float)
362
363   .. versionchanged:: 3.5
364      The function is now retried with a recomputed timeout when interrupted by
365      a signal, except if the signal handler raises an exception (see
366      :pep:`475` for the rationale), instead of raising
367      :exc:`InterruptedError`.
368
369
370.. _poll-objects:
371
372Polling Objects
373---------------
374
375The :c:func:`poll` system call, supported on most Unix systems, provides better
376scalability for network servers that service many, many clients at the same
377time. :c:func:`poll` scales better because the system call only requires listing
378the file descriptors of interest, while :c:func:`select` builds a bitmap, turns
379on bits for the fds of interest, and then afterward the whole bitmap has to be
380linearly scanned again. :c:func:`select` is O(highest file descriptor), while
381:c:func:`poll` is O(number of file descriptors).
382
383
384.. method:: poll.register(fd[, eventmask])
385
386   Register a file descriptor with the polling object.  Future calls to the
387   :meth:`poll` method will then check whether the file descriptor has any
388   pending I/O events.  *fd* can be either an integer, or an object with a
389   :meth:`~io.IOBase.fileno` method that returns an integer.  File objects
390   implement :meth:`!fileno`, so they can also be used as the argument.
391
392   *eventmask* is an optional bitmask describing the type of events you want to
393   check for, and can be a combination of the constants :const:`POLLIN`,
394   :const:`POLLPRI`, and :const:`POLLOUT`, described in the table below.  If not
395   specified, the default value used will check for all 3 types of events.
396
397   +-------------------+------------------------------------------+
398   | Constant          | Meaning                                  |
399   +===================+==========================================+
400   | :const:`POLLIN`   | There is data to read                    |
401   +-------------------+------------------------------------------+
402   | :const:`POLLPRI`  | There is urgent data to read             |
403   +-------------------+------------------------------------------+
404   | :const:`POLLOUT`  | Ready for output: writing will not block |
405   +-------------------+------------------------------------------+
406   | :const:`POLLERR`  | Error condition of some sort             |
407   +-------------------+------------------------------------------+
408   | :const:`POLLHUP`  | Hung up                                  |
409   +-------------------+------------------------------------------+
410   | :const:`POLLRDHUP`| Stream socket peer closed connection, or |
411   |                   | shut down writing half of connection     |
412   +-------------------+------------------------------------------+
413   | :const:`POLLNVAL` | Invalid request: descriptor not open     |
414   +-------------------+------------------------------------------+
415
416   Registering a file descriptor that's already registered is not an error, and has
417   the same effect as registering the descriptor exactly once.
418
419
420.. method:: poll.modify(fd, eventmask)
421
422   Modifies an already registered fd. This has the same effect as
423   ``register(fd, eventmask)``.  Attempting to modify a file descriptor
424   that was never registered causes an :exc:`OSError` exception with errno
425   :const:`ENOENT` to be raised.
426
427
428.. method:: poll.unregister(fd)
429
430   Remove a file descriptor being tracked by a polling object.  Just like the
431   :meth:`register` method, *fd* can be an integer or an object with a
432   :meth:`~io.IOBase.fileno` method that returns an integer.
433
434   Attempting to remove a file descriptor that was never registered causes a
435   :exc:`KeyError` exception to be raised.
436
437
438.. method:: poll.poll([timeout])
439
440   Polls the set of registered file descriptors, and returns a possibly-empty list
441   containing ``(fd, event)`` 2-tuples for the descriptors that have events or
442   errors to report. *fd* is the file descriptor, and *event* is a bitmask with
443   bits set for the reported events for that descriptor --- :const:`POLLIN` for
444   waiting input, :const:`POLLOUT` to indicate that the descriptor can be written
445   to, and so forth. An empty list indicates that the call timed out and no file
446   descriptors had any events to report. If *timeout* is given, it specifies the
447   length of time in milliseconds which the system will wait for events before
448   returning. If *timeout* is omitted, negative, or :const:`None`, the call will
449   block until there is an event for this poll object.
450
451   .. versionchanged:: 3.5
452      The function is now retried with a recomputed timeout when interrupted by
453      a signal, except if the signal handler raises an exception (see
454      :pep:`475` for the rationale), instead of raising
455      :exc:`InterruptedError`.
456
457
458.. _kqueue-objects:
459
460Kqueue Objects
461--------------
462
463.. method:: kqueue.close()
464
465   Close the control file descriptor of the kqueue object.
466
467
468.. attribute:: kqueue.closed
469
470   ``True`` if the kqueue object is closed.
471
472
473.. method:: kqueue.fileno()
474
475   Return the file descriptor number of the control fd.
476
477
478.. method:: kqueue.fromfd(fd)
479
480   Create a kqueue object from a given file descriptor.
481
482
483.. method:: kqueue.control(changelist, max_events[, timeout=None]) -> eventlist
484
485   Low level interface to kevent
486
487   - changelist must be an iterable of kevent object or ``None``
488   - max_events must be 0 or a positive integer
489   - timeout in seconds (floats possible)
490
491   .. versionchanged:: 3.5
492      The function is now retried with a recomputed timeout when interrupted by
493      a signal, except if the signal handler raises an exception (see
494      :pep:`475` for the rationale), instead of raising
495      :exc:`InterruptedError`.
496
497
498.. _kevent-objects:
499
500Kevent Objects
501--------------
502
503https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2
504
505.. attribute:: kevent.ident
506
507   Value used to identify the event. The interpretation depends on the filter
508   but it's usually the file descriptor. In the constructor ident can either
509   be an int or an object with a :meth:`~io.IOBase.fileno` method. kevent
510   stores the integer internally.
511
512.. attribute:: kevent.filter
513
514   Name of the kernel filter.
515
516   +---------------------------+---------------------------------------------+
517   | Constant                  | Meaning                                     |
518   +===========================+=============================================+
519   | :const:`KQ_FILTER_READ`   | Takes a descriptor and returns whenever     |
520   |                           | there is data available to read             |
521   +---------------------------+---------------------------------------------+
522   | :const:`KQ_FILTER_WRITE`  | Takes a descriptor and returns whenever     |
523   |                           | there is data available to write            |
524   +---------------------------+---------------------------------------------+
525   | :const:`KQ_FILTER_AIO`    | AIO requests                                |
526   +---------------------------+---------------------------------------------+
527   | :const:`KQ_FILTER_VNODE`  | Returns when one or more of the requested   |
528   |                           | events watched in *fflag* occurs            |
529   +---------------------------+---------------------------------------------+
530   | :const:`KQ_FILTER_PROC`   | Watch for events on a process id            |
531   +---------------------------+---------------------------------------------+
532   | :const:`KQ_FILTER_NETDEV` | Watch for events on a network device        |
533   |                           | [not available on Mac OS X]                 |
534   +---------------------------+---------------------------------------------+
535   | :const:`KQ_FILTER_SIGNAL` | Returns whenever the watched signal is      |
536   |                           | delivered to the process                    |
537   +---------------------------+---------------------------------------------+
538   | :const:`KQ_FILTER_TIMER`  | Establishes an arbitrary timer              |
539   +---------------------------+---------------------------------------------+
540
541.. attribute:: kevent.flags
542
543   Filter action.
544
545   +---------------------------+---------------------------------------------+
546   | Constant                  | Meaning                                     |
547   +===========================+=============================================+
548   | :const:`KQ_EV_ADD`        | Adds or modifies an event                   |
549   +---------------------------+---------------------------------------------+
550   | :const:`KQ_EV_DELETE`     | Removes an event from the queue             |
551   +---------------------------+---------------------------------------------+
552   | :const:`KQ_EV_ENABLE`     | Permitscontrol() to returns the event       |
553   +---------------------------+---------------------------------------------+
554   | :const:`KQ_EV_DISABLE`    | Disablesevent                               |
555   +---------------------------+---------------------------------------------+
556   | :const:`KQ_EV_ONESHOT`    | Removes event after first occurrence        |
557   +---------------------------+---------------------------------------------+
558   | :const:`KQ_EV_CLEAR`      | Reset the state after an event is retrieved |
559   +---------------------------+---------------------------------------------+
560   | :const:`KQ_EV_SYSFLAGS`   | internal event                              |
561   +---------------------------+---------------------------------------------+
562   | :const:`KQ_EV_FLAG1`      | internal event                              |
563   +---------------------------+---------------------------------------------+
564   | :const:`KQ_EV_EOF`        | Filter specific EOF condition               |
565   +---------------------------+---------------------------------------------+
566   | :const:`KQ_EV_ERROR`      | See return values                           |
567   +---------------------------+---------------------------------------------+
568
569
570.. attribute:: kevent.fflags
571
572   Filter specific flags.
573
574   :const:`KQ_FILTER_READ` and  :const:`KQ_FILTER_WRITE` filter flags:
575
576   +----------------------------+--------------------------------------------+
577   | Constant                   | Meaning                                    |
578   +============================+============================================+
579   | :const:`KQ_NOTE_LOWAT`     | low water mark of a socket buffer          |
580   +----------------------------+--------------------------------------------+
581
582   :const:`KQ_FILTER_VNODE` filter flags:
583
584   +----------------------------+--------------------------------------------+
585   | Constant                   | Meaning                                    |
586   +============================+============================================+
587   | :const:`KQ_NOTE_DELETE`    | *unlink()* was called                      |
588   +----------------------------+--------------------------------------------+
589   | :const:`KQ_NOTE_WRITE`     | a write occurred                           |
590   +----------------------------+--------------------------------------------+
591   | :const:`KQ_NOTE_EXTEND`    | the file was extended                      |
592   +----------------------------+--------------------------------------------+
593   | :const:`KQ_NOTE_ATTRIB`    | an attribute was changed                   |
594   +----------------------------+--------------------------------------------+
595   | :const:`KQ_NOTE_LINK`      | the link count has changed                 |
596   +----------------------------+--------------------------------------------+
597   | :const:`KQ_NOTE_RENAME`    | the file was renamed                       |
598   +----------------------------+--------------------------------------------+
599   | :const:`KQ_NOTE_REVOKE`    | access to the file was revoked             |
600   +----------------------------+--------------------------------------------+
601
602   :const:`KQ_FILTER_PROC` filter flags:
603
604   +----------------------------+--------------------------------------------+
605   | Constant                   | Meaning                                    |
606   +============================+============================================+
607   | :const:`KQ_NOTE_EXIT`      | the process has exited                     |
608   +----------------------------+--------------------------------------------+
609   | :const:`KQ_NOTE_FORK`      | the process has called *fork()*            |
610   +----------------------------+--------------------------------------------+
611   | :const:`KQ_NOTE_EXEC`      | the process has executed a new process     |
612   +----------------------------+--------------------------------------------+
613   | :const:`KQ_NOTE_PCTRLMASK` | internal filter flag                       |
614   +----------------------------+--------------------------------------------+
615   | :const:`KQ_NOTE_PDATAMASK` | internal filter flag                       |
616   +----------------------------+--------------------------------------------+
617   | :const:`KQ_NOTE_TRACK`     | follow a process across *fork()*           |
618   +----------------------------+--------------------------------------------+
619   | :const:`KQ_NOTE_CHILD`     | returned on the child process for          |
620   |                            | *NOTE_TRACK*                               |
621   +----------------------------+--------------------------------------------+
622   | :const:`KQ_NOTE_TRACKERR`  | unable to attach to a child                |
623   +----------------------------+--------------------------------------------+
624
625   :const:`KQ_FILTER_NETDEV` filter flags (not available on Mac OS X):
626
627   +----------------------------+--------------------------------------------+
628   | Constant                   | Meaning                                    |
629   +============================+============================================+
630   | :const:`KQ_NOTE_LINKUP`    | link is up                                 |
631   +----------------------------+--------------------------------------------+
632   | :const:`KQ_NOTE_LINKDOWN`  | link is down                               |
633   +----------------------------+--------------------------------------------+
634   | :const:`KQ_NOTE_LINKINV`   | link state is invalid                      |
635   +----------------------------+--------------------------------------------+
636
637
638.. attribute:: kevent.data
639
640   Filter specific data.
641
642
643.. attribute:: kevent.udata
644
645   User defined value.
646