def sysTestRunner(workload): bucket = str(workload.bucket) latestWorkloadTask = None prevWorkload = None cache = BucketStatusCacher() bucketStatus = cache.bucketstatus(bucket) if bucketStatus is not None: latestWorkloadTask, prevWorkload = bucketStatus.latestWorkloadTask(bucket) else: bucketStatus = BucketStatus(bucket) # make this the latest taskid against this bucket bucketStatus.addTask(bucket, current_task.request.id, workload) cache.store(bucketStatus) if workload.wait is not None: # wait before processing time.sleep(workload.wait) if bucketStatus.mode(bucket) == "blocking": while Cache().retrieve(prevWorkload.id) is not None: time.sleep(2) elif bucketStatus.mode(bucket) == "nonblocking": if prevWorkload is not None: # disable previously running # workload if bucket in nonblocking mode. # if current workload has no preconditions # it's not allowed to override previous workload if workload.preconditions is None: prevWorkload.active = False WorkloadCacher().store(prevWorkload) runTask = run.apply_async(args=[workload, prevWorkload], expires = workload.expires) return runTask.get()
def sysTestRunner(workload): bucket = str(workload.bucket) latestWorkloadTask = None prevWorkload = None cache = BucketStatusCacher() bucketStatus = cache.bucketstatus(bucket) if bucketStatus is not None: latestWorkloadTask, prevWorkload = bucketStatus.latestWorkloadTask( bucket) else: bucketStatus = BucketStatus(bucket) # make this the latest taskid against this bucket bucketStatus.addTask(bucket, current_task.request.id, workload) cache.store(bucketStatus) if workload.wait is not None: # wait before processing time.sleep(workload.wait) if bucketStatus.mode(bucket) == "blocking": while Cache().retrieve(prevWorkload.id) is not None: time.sleep(2) elif bucketStatus.mode(bucket) == "nonblocking": if prevWorkload is not None: # disable previously running # workload if bucket in nonblocking mode. # if current workload has no preconditions # it's not allowed to override previous workload if workload.preconditions is None: prevWorkload.active = False WorkloadCacher().store(prevWorkload) runTask = run.apply_async(args=[workload, prevWorkload], expires=workload.expires) return runTask.get()