Files
bg/test1.test
2020-06-21 16:09:21 -07:00

25 lines
629 B
Python
Executable File

#!/usr/bin/env python3
import time
from bg import Bg
def process(secs, preamble=None, epilogue=None):
if preamble:
print("PREAMBLE:", preamble)
time.sleep(secs)
if epilogue:
print("EPILOGUE:", epilogue)
return 3.1415
print("Starting test")
job = Bg(process, 6.0, preamble="Starting background job", epilogue="Finishing background process")
for i in range(3):
if job.is_running():
print("[%s] Job is still running" % i)
time.sleep(0.5)
if job.is_running():
print("You know what, I'll just wait")
job.wait()
print("Seems like it's done!")
print("Result: %s" % job.result)