Skip to main content

Process IO Watcher

Project description

Watchio

WatchIO - Python package to watch process IO.

The watchio package provides utilities to watch for IO activities of Unix processes. It works by reading the Unix process information file /proc/{pid}/io periodically. You can only use it on a system where /proc is mounted, and for processes that you have tracing access to.

An example use case is a microserver displaying static web pages created by a separate program that takes a moderate amount of resources. A sensible implementation updates the static pages only when users are viewing the results. The watchio module helps to watch for IO activities of the server when the server has no other convenient indications of activities (such as saving accesses to a log file).

Install the package from pypi.org by

pip install watchio

Usage

In a polling loop in Python code:

watcher = watchio.WatchIO([123, 456])

## Use in a polling loop to update static web pages
## poll() will return an integer
##    -1:  every 600 seconds, or
##    >0:  there are IO activities (checked every 10 seconds)
while True:
    if watcher.poll(timeout=600, step=10):
        ## main work
        ....

On the Unix command line

watchio poll 1234 vim --timeout 600 --step 10
./update_script.csh

Only processes owned by you are allowed. You can supply a process name instead of a numerical process ID and watchio will look up all processes owned by you having that name.

See Also

Project Information

python-depends: psutil
docs: mkdocs
python-modules:  watchio
python-packages: watchio

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

watchio-0.0.40.tar.gz (16.7 kB view hashes)

Uploaded Source

Built Distribution

watchio-0.0.40-py3-none-any.whl (17.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page