Make the loop pause when we run out of builder capacity.
This commit is contained in:
		
							parent
							
								
									7ee00b83cb
								
							
						
					
					
						commit
						63d23a04c0
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		|  | @ -139,14 +139,15 @@ class BuilderServer(object): | ||||||
|   @trollius.coroutine |   @trollius.coroutine | ||||||
|   def _work_checker(self): |   def _work_checker(self): | ||||||
|     while self._current_status == 'running': |     while self._current_status == 'running': | ||||||
|  |       with database.CloseForLongOperation(app.config): | ||||||
|  |         yield From(trollius.sleep(WORK_CHECK_TIMEOUT)) | ||||||
|  | 
 | ||||||
|       logger.debug('Checking for more work for %d active workers', |       logger.debug('Checking for more work for %d active workers', | ||||||
|                    self._lifecycle_manager.num_workers()) |                    self._lifecycle_manager.num_workers()) | ||||||
| 
 | 
 | ||||||
|       job_item = self._queue.get(processing_time=self._lifecycle_manager.setup_time()) |       job_item = self._queue.get(processing_time=self._lifecycle_manager.setup_time()) | ||||||
|       if job_item is None: |       if job_item is None: | ||||||
|         logger.debug('No additional work found. Going to sleep for %s seconds', WORK_CHECK_TIMEOUT) |         logger.debug('No additional work found. Going to sleep for %s seconds', WORK_CHECK_TIMEOUT) | ||||||
|         with database.CloseForLongOperation(app.config): |  | ||||||
|           yield From(trollius.sleep(WORK_CHECK_TIMEOUT)) |  | ||||||
|         continue |         continue | ||||||
| 
 | 
 | ||||||
|       try: |       try: | ||||||
|  | @ -164,6 +165,8 @@ class BuilderServer(object): | ||||||
|         logger.debug('All workers are busy. Requeuing.') |         logger.debug('All workers are busy. Requeuing.') | ||||||
|         self._queue.incomplete(job_item, restore_retry=True, retry_after=0) |         self._queue.incomplete(job_item, restore_retry=True, retry_after=0) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|   @trollius.coroutine |   @trollius.coroutine | ||||||
|   def _initialize(self, loop, host, websocket_port, controller_port, ssl=None): |   def _initialize(self, loop, host, websocket_port, controller_port, ssl=None): | ||||||
|     self._loop = loop |     self._loop = loop | ||||||
|  |  | ||||||
		Reference in a new issue