File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Original file line number Diff line number Diff line change @@ -5058,6 +5058,8 @@ information, consult your Unix manpages.
5058
5058
The following scheduling policies are exposed if they are supported by the
5059
5059
operating system.
5060
5060
5061
+ .. _os-scheduling-policy :
5062
+
5061
5063
.. data :: SCHED_OTHER
5062
5064
5063
5065
The default scheduling policy.
@@ -5149,7 +5151,7 @@ operating system.
5149
5151
5150
5152
.. function :: sched_yield()
5151
5153
5152
- Voluntarily relinquish the CPU.
5154
+ Voluntarily relinquish the CPU. See :manpage: `sched_yield(2)` for details.
5153
5155
5154
5156
5155
5157
.. function :: sched_setaffinity(pid, mask, /)
Original file line number Diff line number Diff line change @@ -367,6 +367,8 @@ Functions
367
367
The suspension time may be longer than requested by an arbitrary amount,
368
368
because of the scheduling of other activity in the system.
369
369
370
+ .. rubric :: Windows implementation
371
+
370
372
On Windows, if *secs * is zero, the thread relinquishes the remainder of its
371
373
time slice to any other thread that is ready to run. If there are no other
372
374
threads ready to run, the function returns immediately, and the thread
@@ -375,12 +377,19 @@ Functions
375
377
<https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers> `_
376
378
which provides resolution of 100 nanoseconds. If *secs * is zero, ``Sleep(0) `` is used.
377
379
378
- Unix implementation:
380
+ .. rubric :: Unix implementation
379
381
380
382
* Use ``clock_nanosleep() `` if available (resolution: 1 nanosecond);
381
383
* Or use ``nanosleep() `` if available (resolution: 1 nanosecond);
382
384
* Or use ``select() `` (resolution: 1 microsecond).
383
385
386
+ .. note ::
387
+
388
+ To emulate a "no-op", use :keyword: `pass ` instead of ``time.sleep(0) ``.
389
+
390
+ To voluntarily relinquish the CPU, specify a real-time :ref: `scheduling
391
+ policy <os-scheduling-policy>` and use :func: `os.sched_yield ` instead.
392
+
384
393
.. versionchanged :: 3.5
385
394
The function now sleeps at least *secs * even if the sleep is interrupted
386
395
by a signal, except if the signal handler raises an exception (see
You can’t perform that action at this time.
0 commit comments