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


.. code-block:: python
        import pynisher
        import time

        # using it as a decorator for every call to this function
        @pynisher.enforce_limits(wall_time_in_s=2)
        def my_function (t):
        	time.sleep(t)
        	return(t)

        for t in range(5):
        	print(my_function(t))

        # a more explicit usage

        def my_other_function(t):
	        time.sleep(t)
	        return(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)<commit_msg>stupid typo in README.rst<commit_after>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.


.. code-block:: python

        import pynisher
        import time

        # using it as a decorator for every call to this function
        @pynisher.enforce_limits(wall_time_in_s=2)
        def my_function (t):
        	time.sleep(t)
        	return(t)

        for t in range(5):
        	print(my_function(t))

        # a more explicit usage

        def my_other_function(t):
	        time.sleep(t)
	        return(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)
{'fraction_non_alphanumeric': 0.058174097664543525, 'fraction_numerical': 0.0025477707006369425, 'mean_word_length': 3.006802721088435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2160892', 'n_tokens_mistral': 645, 'n_tokens_neox': 615, 'n_words': 278}