0

To elaborate, I need the script to check whether the system is connected to wifi ( using infinite busy wait loop) and once it connects, the script resumes to do whatever it wants to do next..

This works but as you can see, it wastes CPU time (it usually takes about 5-8 seconds to connect to wifi) .. now, might add a timer to only check at regular intervals, but is there a way to just 'pause' the script and 'signal'/'resume' it till the wifi is connected

PS: To check whether wifi is connected or not, I'm using

hostname -I

in Python script which returns a value if connected and null otherwise.

  • 1
    You might be able to do something with Python's async constructs. Instead of a busy wait, you could use the `asyncio` version of `sleep` that frees up the CPU to work on other stuff while "sleeping", then just check in every couple seconds to see if you're connected. [Here](https://docs.python.org/3/library/asyncio-task.html) would be a good place to start if you want to go down that road. And [here](https://stackoverflow.com/questions/56729764/python-3-7-asyncio-sleep-and-time-sleep) for the difference between the two types of `sleep`. – Carcigenicate Apr 09 '20 at 22:27
  • But the time for sleep would be static ... Is there any way in which the os signals the script in some way once the command gets some output .. – Vivek Nehra Apr 10 '20 at 09:51

0 Answers0