File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -149,10 +149,18 @@ Methods
149
149
150
150
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating
151
151
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
153
153
completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
154
154
is put in blocking mode.
155
155
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
+
156
164
.. method :: socket.setblocking(flag)
157
165
158
166
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking,
You can’t perform that action at this time.
0 commit comments