views:

191

answers:

2

hi expert, i've dev code for wifi scanning in python, now i trying to modify my code so it will scan wifi at specific interval, how this can be done

thanks

+3  A: 

You generally have two solutions:

  • schedule to run the python script which refreshes WIFI info at various interval, using crontab or similar external device.

  • keep the [python] program running and use threading.timer to schedule calls to the WIFI checking routine at desired intervals.

mjv
+3  A: 

If you want it all within a long-running Python process (as opposed to a more normal cron-run script), the sched module in the Python standard library is probably the best way to schedule periodically repeated execution of a function or other callable (key trick: to schedule periodically, have each execution schedule the next one at appropriate delay -- the very classic, language-independent pattern to turn one-off scheduling into periodic repeats).

Alex Martelli
Them batteries again ;-) When in doubt, check the std lib! Not that I have much use for scheduled events, but it's good to know it's there. Actually, I may use more, now, for eg. for unit tests of asynch processes. Thks!
mjv