Simple test
This commit is contained in:
24
test1.test
Executable file
24
test1.test
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user