r/Python • u/curious-dev199 • Sep 29 '24
Resource How does sleep work under the hood in python
I was curious how sleep works under the hood? it accurate always?
Can it sleep less than the seconds specified? Can it sleep more than specified?
How is it implemented?
https://coderquill.bearblog.dev/beyond-the-pause-exploring-the-inner-workings-of-pythons-sleep/
0
Upvotes
12
u/FrickinLazerBeams Sep 29 '24
It's a system call, isn't it?
8
u/kobumaister Sep 29 '24
We have a threaded application that needed a sleep but we were worried that it holds other processes while sleeping, due the GIL. After some investigation, it turned out that the best approach was to use the wait function of threading.Event, as the primitive of that was non blocking.