Move some timeout conditionals to concerned models
This commit is contained in:
		
							parent
							
								
									d007dfe3ff
								
							
						
					
					
						commit
						6027bf15c1
					
				| @ -63,7 +63,7 @@ class ActivityTask(object): | ||||
|         self.last_heartbeat_timestamp = now_timestamp() | ||||
| 
 | ||||
|     def first_timeout(self): | ||||
|         if not self.workflow_execution.open: | ||||
|         if not self.open or not self.workflow_execution.open: | ||||
|             return None | ||||
|         # TODO: handle the "NONE" case | ||||
|         heartbeat_timeout_at = self.last_heartbeat_timestamp + \ | ||||
|  | ||||
| @ -24,6 +24,10 @@ class DecisionTask(object): | ||||
|         self.scheduled_at = datetime.now() | ||||
|         self.timeout_type = None | ||||
| 
 | ||||
|     @property | ||||
|     def started(self): | ||||
|         return self.state == "STARTED" | ||||
| 
 | ||||
|     def _check_workflow_execution_open(self): | ||||
|         if not self.workflow_execution.open: | ||||
|             raise SWFWorkflowExecutionClosedError() | ||||
| @ -53,7 +57,7 @@ class DecisionTask(object): | ||||
|         self.state = "COMPLETED" | ||||
| 
 | ||||
|     def first_timeout(self): | ||||
|         if self.state != "STARTED" or not self.workflow_execution.open: | ||||
|         if not self.started or not self.workflow_execution.open: | ||||
|             return None | ||||
|         # TODO: handle the "NONE" case | ||||
|         start_to_close_at = self.started_timestamp + int(self.start_to_close_timeout) | ||||
|  | ||||
| @ -166,7 +166,7 @@ class WorkflowExecution(object): | ||||
|         # decision tasks timeouts | ||||
|         for task in self.decision_tasks: | ||||
|             _timeout = task.first_timeout() | ||||
|             if task.state == "STARTED" and _timeout: | ||||
|             if _timeout: | ||||
|                 self.should_schedule_decision_next = True | ||||
|                 task.timeout(_timeout) | ||||
|                 self._add_event( | ||||
| @ -180,7 +180,7 @@ class WorkflowExecution(object): | ||||
|         # activity tasks timeouts | ||||
|         for task in self.activity_tasks: | ||||
|             _timeout = task.first_timeout() | ||||
|             if task.open and _timeout: | ||||
|             if _timeout: | ||||
|                 self.should_schedule_decision_next = True | ||||
|                 task.timeout(_timeout) | ||||
|                 self._add_event( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user