Avoid comparision between "None" type and "int" type.
In py34, if NoneType object is compared to int value it raises exception. In unit test following type of error is occured. "TypeError: unorderable types: NoneType() >= int()". Change-Id: Ibc7329824324edbe30976d460d389299824574ce Partially-Implements: blueprint mistral-py3
This commit is contained in:
parent
8370cc56f5
commit
9dfd42e450
@ -43,7 +43,7 @@ class ExecutionExpirationPolicy(periodic_task.PeriodicTasks):
|
||||
interval = CONF.execution_expiration_policy.evaluation_interval
|
||||
older_than = CONF.execution_expiration_policy.older_than
|
||||
|
||||
if (interval and older_than >= 1):
|
||||
if (interval and older_than and older_than >= 1):
|
||||
_periodic_task = periodic_task.periodic_task(
|
||||
spacing=interval * 60,
|
||||
run_immediately=True
|
||||
|
@ -51,7 +51,8 @@ class MistralPeriodicTasks(periodic_task.PeriodicTasks):
|
||||
**t.workflow_params
|
||||
)
|
||||
finally:
|
||||
if t.remaining_executions > 0:
|
||||
if (t.remaining_executions is not None and
|
||||
t.remaining_executions > 0):
|
||||
t.remaining_executions -= 1
|
||||
if t.remaining_executions == 0:
|
||||
db_api_v2.delete_cron_trigger(t.name)
|
||||
|
@ -45,7 +45,7 @@ def validate_cron_trigger_input(pattern, first_time, count):
|
||||
raise exc.InvalidModelException(
|
||||
'first_execution_time must be at least 1 second in the future.'
|
||||
)
|
||||
if not pattern and count > 1:
|
||||
if not pattern and count and count > 1:
|
||||
raise exc.InvalidModelException(
|
||||
'Pattern must be provided if count is superior to 1.'
|
||||
)
|
||||
|
@ -111,9 +111,10 @@ def get_indices_for_loop(task_ex):
|
||||
def decrease_capacity(task_ex, count):
|
||||
with_items_context = _get_context(task_ex)
|
||||
|
||||
if with_items_context[_CAPACITY] is not None:
|
||||
if with_items_context[_CAPACITY] >= count:
|
||||
with_items_context[_CAPACITY] -= count
|
||||
elif with_items_context[_CAPACITY]:
|
||||
else:
|
||||
raise exc.WorkflowException(
|
||||
"Impossible to apply current with-items concurrency."
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user