select.rst 1.13 KB
Newer Older
1
2
:mod:`select` -- Provides select function to wait for events on a stream
========================================================================
3
4
5
6
7
8

.. module:: select
   :synopsis: Provides select function to wait for events on a stream

This module provides the select function.

9
10
11
12
13
14
Pyboard specifics
-----------------

Polling is an efficient way of waiting for read/write activity on multiple
objects.  Current objects that support polling are: :class:`pyb.UART`,
:class:`pyb.USB_VCP`.
15
16
17
18
19
20

Functions
---------

.. function:: poll()

21
   Create an instance of the Poll class.
22
23
24

.. function:: select(rlist, wlist, xlist[, timeout])

25
   Wait for activity on a set of objects.
26

27
.. _class: Poll
28

29
30
class ``Poll``
--------------
31
32

Methods
33
~~~~~~~
34

35
.. method:: poll.register(obj[, eventmask])
36

37
38
   Register ``obj`` for polling.  ``eventmask`` is 1 for read, 2 for
   write, 3 for read-write.
39

40
.. method:: poll.unregister(obj)
41

42
   Unregister ``obj`` from polling.
43

44
.. method:: poll.modify(obj, eventmask)
45

46
   Modify the ``eventmask`` for ``obj``.
47

48
49
50
.. method:: poll.poll([timeout])

   Wait for one of the registered objects to become ready.
51

52
   Timeout is in milliseconds.