Debian Codegraph @

Doc/library/select.rst

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