The Blinker.run() takes 100%CPU power
Closed this issue · 3 comments
Since the thread_run() function will busy loop polling checkData, the CPU core will be occupied 100% by Blinker library. Suggest add a small sleep like time.sleep(0.1) after checkData() in thread_run() function.
Plus, it's good if we could change the demo program as follow:
...
if name == 'main':
while True:
Blinker.run()
time.sleep(0.1)
...
Try to add "time.sleep(0.1)" in entry point, below "Blinker.run()" code blocks, still 100% occupied
It would give way itself. If other programmes need that CPU power it would let go and won't occupy it. That said, it is good to limit the CPU usage.
I tried time.sleep(0.5)
and it went just fine.
Edit: I found out a programme on linux called cpulimit
that could limit CPU usage. That might be a workaround. You need to install it first, then execute the python script, and execute this command in the same shell right after that.
sudo cpulimit --pid $! --limit 20 --background --lazy
It would limit the proccess to 20% CPU usage, and run in background. If the proccess ended, it would exit too.
@SodaWithoutSparkles @victorhe10 @justinwuchina 我们已重构py支持库,在新版库中已解决该问题。期待你们的测试和反馈。