Simple test

This commit is contained in:
2020-06-21 16:09:21 -07:00
parent 5807dc1f28
commit 7498595782
3 changed files with 32 additions and 0 deletions

0
test1.stderr Normal file
View File

8
test1.stdout Normal file
View File

@@ -0,0 +1,8 @@
Starting test
PREAMBLE: Starting background job
[1] Job is still running
[2] Job is still running
You know what, I'll just wait
EPILOGUE: Finishing background process
Seems like it's done!
Result: 3.1415

24
test1.test Executable file
View 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)