开发者

python interval

i've dev code开发者_如何学Python 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


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜