Various ways to implement a daemon that pings remote hosts.
images | first commit. | 2019-07-05 20:08:07 |
---|---|---|
LICENSE.txt | first commit. | 2019-07-05 20:08:07 |
README.md | first commit. | 2019-07-05 20:08:07 |
long_lived_looping_workers.py | first commit. | 2019-07-05 20:08:07 |
long_lived_worker_queue.py | first commit. | 2019-07-05 20:08:07 |
short_lived_workers.py | first commit. | 2019-07-05 20:08:07 |
These are different approaches to how one might implement a daemon to repeatedly ping multiple hosts to see if the network is up.
This is the most naive implementation. For each ping host, the main process thread pings them one at a time, and prints any changes.
Really simple code.
Since the pings are serialized, one long timeout from one host could affect detecting a problem at another host.
Raymond Hettinger's PyBay 2018 Keynote uses the queue module to send data between threads, so I thought I'd make a version of the pinger that did the same.
Multi-threaded ping calls won't block each other.
The ping tasks read from, and write to a shared dictionary. (Reading and updating the last status.)
The worker tasks aren't in memory if they're not doing anything. So usually a smaller memory profile.
The ping tasks still read from, and write to a shared dictionary. (Reading and updating the last status.)
No more race conditions! The worker threads mind their own business.
The worker threads remain in memory.
Yes.
This software uses the MIT license.