File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -5358,6 +5358,8 @@ information, consult your Unix manpages.
5358
5358
The following scheduling policies are exposed if they are supported by the
5359
5359
operating system.
5360
5360
5361
+ .. _os-scheduling-policy :
5362
+
5361
5363
.. data :: SCHED_OTHER
5362
5364
5363
5365
The default scheduling policy.
@@ -5449,7 +5451,7 @@ operating system.
5449
5451
5450
5452
.. function :: sched_yield()
5451
5453
5452
- Voluntarily relinquish the CPU.
5454
+ Voluntarily relinquish the CPU. See :manpage: `sched_yield(2)` for details.
5453
5455
5454
5456
5455
5457
.. function :: sched_setaffinity(pid, mask, /)
Original file line number Diff line number Diff line change @@ -385,6 +385,8 @@ Functions
385
385
The suspension time may be longer than requested by an arbitrary amount,
386
386
because of the scheduling of other activity in the system.
387
387
388
+ .. rubric :: Windows implementation
389
+
388
390
On Windows, if *secs * is zero, the thread relinquishes the remainder of its
389
391
time slice to any other thread that is ready to run. If there are no other
390
392
threads ready to run, the function returns immediately, and the thread
@@ -393,12 +395,19 @@ Functions
393
395
<https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers> `_
394
396
which provides resolution of 100 nanoseconds. If *secs * is zero, ``Sleep(0) `` is used.
395
397
396
- Unix implementation:
398
+ .. rubric :: Unix implementation
397
399
398
400
* Use ``clock_nanosleep() `` if available (resolution: 1 nanosecond);
399
401
* Or use ``nanosleep() `` if available (resolution: 1 nanosecond);
400
402
* Or use ``select() `` (resolution: 1 microsecond).
401
403
404
+ .. note ::
405
+
406
+ To emulate a "no-op", use :keyword: `pass ` instead of ``time.sleep(0) ``.
407
+
408
+ To voluntarily relinquish the CPU, specify a real-time :ref: `scheduling
409
+ policy <os-scheduling-policy>` and use :func: `os.sched_yield ` instead.
410
+
402
411
.. audit-event :: time.sleep secs
403
412
404
413
.. versionchanged :: 3.5
You can’t perform that action at this time.
0 commit comments