Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

A small Python library to limit the resources used by a function by executing it inside a subprocess.

Project description

The pynisher is a little module intended to limit a functions resources. It starts a new process, sets the desired limits, and executes the function inside it. In the end, it returns the function return value. If, for any reason, the function call is not successful, None is returned.

Currently, the total memory usage(*), the wall clock time, the cpu time and the number of processes can be limited.

(*) As the subprocess also includes the Python interpreter, the actual memory available to your function is less than the specified value.

import pynisher
import time

# using it as a decorator for every call to this function
def my_function (t):

for t in range(5):

# a more explicit usage

def my_other_function(t):

# explicitly create a new function without wrapping the original everytime
my_wrapped_function = pynisher.enforce_limits(wall_time_in_s=3)(my_other_function)

for t in range(5):

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
pynisher-0.3.1.linux-x86_64.tar.gz (4.6 kB) Copy SHA256 hash SHA256 Dumb Binary any Jan 14, 2016
pynisher-0.3.1.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None Jan 14, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page