Skip to content

A simple python package for calling a function N times per second, while taking into account the execution time of the function being called

License

Notifications You must be signed in to change notification settings

senox13/limitloop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Limitloop

Limitloop is a lightweight python module for running loops that depend on precise timing.

This package is available through Pypi and can be installed with the following command.

python -m pip install limitloop

Basic usage

All functionality of the module is provided through the limitloop.Loop class. This class is instantiated with a reference to a function, which it can then call at a consistent rate a preset number of times, or until otherwise interrupted. For example, the following code...

from limitloop import Loop

#Define a simple function for the Loop object to call
#This function must accept the loop object itself as its first argument
def demoFunction(loop):
    print('Hello, world!')

#Create our loop object, set to run at one iteration per second
l = Loop(demoFunction, freq=1)
#Call the function defined above 5 times
l.run(5)

...will output the following, one line per second.

Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!

See the API reference for more advanced usage.

About

A simple python package for calling a function N times per second, while taking into account the execution time of the function being called

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages