Simple test
This commit is contained in:
0
test1.stderr
Normal file
0
test1.stderr
Normal file
8
test1.stdout
Normal file
8
test1.stdout
Normal 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
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