diff --git a/test1.stderr b/test1.stderr new file mode 100644 index 0000000..e69de29 diff --git a/test1.stdout b/test1.stdout new file mode 100644 index 0000000..a03ae82 --- /dev/null +++ b/test1.stdout @@ -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 diff --git a/test1.test b/test1.test new file mode 100755 index 0000000..0e77a2f --- /dev/null +++ b/test1.test @@ -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)