Skip to main content

Package to monitor and throttle multiple processes or threads.

Project description


A Python package to monitor and throttle multiprocessing processes.

Use case:

This package can be used to control and monitor Pythons multiprocessing processes or threading threads. The central Throttle class can be used to monitor the current and the mean frequency of processes/threads and/or to throttle them to execute a limited times per second. This can be used to limit the server requests of a multi-process web crawler.


    import multiprocessing
    import mp_throttle
    import time

    def work(tank):
        while not tank.kill_flag.is_set():
            # Block until 'fuel' is available.
            # do something

    # Limit the processes to 4 per 1 second, by providing 4 'fuel' per second.
    throttle = mp_throttle.Throttle(4,1)
    workerpool = multiprocessing.Pool(processes=4, initializer=work, initargs=(throttle,))
    # Stops the processes and return stats:
    runtime, total_processes, mean_frequency, mean_processes_per_second = throttle.stop()
    print("Runtime: {}".format(runtime))
    print("Total: {}".format(total_processes))
    print("Mean frequency: {}".format(mean_frequency))
    print("Processes per second: {}".format(mean_processes_per_second))


>>> Runtime: 5.027516841888428
>>> Total: 20
>>> Mean frequency: 0.25046865940093993
>>> Processes per second: 3.9925154803469485


To install mp_throttle, simply use pip:

pip install mp_throttle


For the full documentation see

How to Contribute:

  1. Test mp_throttle and open an issue to report a bug or discuss a feature idea.
  2. Give general feedback on the code and the package structure. Since this is my first python package, I'm sure there is a lot to feedback on:)
  3. Fork the repository and make your changes.

Project details

Download files

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

Files for mp-throttle, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size mp_throttle-0.0.5-py3-none-any.whl (5.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mp_throttle-0.0.5.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page