8000 docs/usocket: Clarify that socket timeout raises OSError exception. · boneskull/circuitpython@a1a8f01 · GitHub
[go: up one dir, main page]

Skip to content

Commit a1a8f01

Browse files
committed
docs/usocket: Clarify that socket timeout raises OSError exception.
1 parent ef1bbad commit a1a8f01

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/library/usocket.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,18 @@ Methods
149149

150150
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating
151151
point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations
152-
will raise a timeout exception if the timeout period value has elapsed before the operation has
152+
will raise an ``OSError`` exception if the timeout period value has elapsed before the operation has
153153
completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
154154
is put in blocking mode.
155155

156+
.. admonition:: Difference to CPython
157+
:class: attention
158+
159+
CPython raises a ``socket.timeout`` exception in case of timeout,
160+
which is an ``OSError`` subclass. MicroPython raises an OSError directly
161+
instead. If you use ``except OSError:`` to catch the exception,
162+
your code will work both in MicroPython and CPython.
163+
156164
.. method:: socket.setblocking(flag)
157165

158166
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking,

0 commit comments

Comments
 (0)
0