Skip to main content

blocker to block programs until an event happens

Project description

ProTimer

blocker to block programs until an event happens

installation

Run the following to install:

pip install ProTimer

or

python -m pip install ProTimer

if that didn't work, try replacing pip with pip3. need help? my discord: lab

two test programs

Warning the two programs may not start at the exact time

import time
from ProTimer import timer
from ProTimer import system
timer = timer(10)
# this must be in one of the programs
timer.start() # start a timer
system.sleep() # block the program for timer(s)
for i in range(10):
	time.sleep(1)
	print(i,flush=True)

Warning don't put timer Object in two programs at the same time

import time
from ProTimer import system
system.sleep() # timer(10s) blocking
for i in range(10):
	time.sleep(1)
	print(i,flush=True)

Note you must start the programs at the same time or start at close time

system class

sleep

wait until a time ends

system.sleep()

is_running

if a process is running or not
"""
return a booling
if is running return True
else is not running return False
"""
# pids can be None
system.is_running(process.name,process.pids)

run_until

wait until the process is finish

# pids is None by default
system.run_until(process.name,process.pids)

run_until_completed

wait until the process is finish with timeout

# pids is None by default
# timeout is by (default is 10)
system.run_until_completed(process.name,process.pids,timeout=timeout)

timerquit

if the function took too long it raise KeyboardInterrupt

exit_after

@timerquit.exit_after(9)
def foo(bar):
    print ('hello {0}'.format(bar))
    time.sleep(10)
    return ("foo")
try:
	print(foo(bar="hello"))
except KeyboardInterrupt:
	pass

Change Log

0.1.0 (2022/07/7)

  • First Release

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

ProTimer-0.1.0.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

ProTimer-0.1.0-py3-none-any.whl (6.9 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