From b51e8c0837354eba4e234a1f9bcf0ecd630d2ae0 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 15 Jan 2008 15:26:13 -0500 Subject: Jobthing is now functional (see async_test.py for example usage), we still need to delete jobs that have expired after a certain amount of time to avoid keeping too many results around in storage. --- test/async_test.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/async_test.py (limited to 'test') diff --git a/test/async_test.py b/test/async_test.py new file mode 100644 index 0000000..4c1acf5 --- /dev/null +++ b/test/async_test.py @@ -0,0 +1,38 @@ +from func.overlord.client import Client +import func.overlord.jobthing as jobthing +import time +import sys + +TEST_SLEEP = 5 +EXTRA_SLEEP = 5 + +def __tester(async): + if async: + client = Client("*",nforks=10,async=True) + oldtime = time.time() + print "asking minion to sleep for %s seconds" % TEST_SLEEP + job_id = client.test.sleep(TEST_SLEEP) + print "job_id = %s" % job_id + while True: + status = client.job_status(job_id) + (code, results) = status + nowtime = time.time() + delta = int(nowtime - oldtime) + if nowtime > oldtime + TEST_SLEEP + EXTRA_SLEEP: + print "time expired, test failed" + sys.exit(1) + if code == jobthing.JOB_ID_RUNNING: + print "task is still running, %s elapsed ..." % delta + elif code == jobthing.JOB_ID_FINISHED: + print "task complete, %s elapsed, results = %s" % (delta, results) + sys.exit(0) + else: + print "job not found: %s, %s elapased" % (code, delta) + time.sleep(1) + else: + print Client("*",nforks=10,async=False).test.sleep(5) + +# __tester(False) +__tester(True) + + -- cgit