Even more generalized exception handling
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone Build is passing
				
			This commit is contained in:
		
							
								
								
									
										36
									
								
								camdetect.py
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								camdetect.py
									
									
									
									
									
								
							| @@ -27,39 +27,36 @@ THRESHOLD_BLOCKS = 20 | |||||||
| THRESHOLD_MOTION_START = 2 | THRESHOLD_MOTION_START = 2 | ||||||
|  |  | ||||||
| counter_dropped_bytes = Counter( | counter_dropped_bytes = Counter( | ||||||
|     "camtiler_client_dropped_bytes", |     "camdetect_dropped_bytes", | ||||||
|     "Bytes that were not not handled or part of actual JPEG frames") |     "Bytes that were not not handled or part of actual JPEG frames") | ||||||
| counter_rx_bytes = Counter( | counter_rx_bytes = Counter( | ||||||
|     "camtiler_client_rx_bytes", |     "camdetect_rx_bytes", | ||||||
|     "Bytes received over HTTP stream") |     "Bytes received over HTTP stream") | ||||||
| counter_tx_bytes = Counter( | counter_tx_bytes = Counter( | ||||||
|     "camtiler_client_tx_bytes", |     "camdetect_tx_bytes", | ||||||
|     "Bytes transmitted over HTTP streams") |     "Bytes transmitted over HTTP streams") | ||||||
| counter_rx_frames = Counter( | counter_rx_frames = Counter( | ||||||
|     "camtiler_client_rx_frames", |     "camdetect_rx_frames", | ||||||
|     "Frames received") |     "Frames received") | ||||||
| counter_tx_frames = Counter( | counter_tx_frames = Counter( | ||||||
|     "camtiler_client_tx_frames", |     "camdetect_tx_frames", | ||||||
|     "Frames transmitted") |     "Frames transmitted") | ||||||
| counter_tx_events = Counter( | counter_tx_events = Counter( | ||||||
|     "camtiler_client_tx_events", |     "camdetect_tx_events", | ||||||
|     "Events emitted") |     "Events emitted") | ||||||
| counter_eos = Counter( | counter_errors =  Counter( | ||||||
|     "camtiler_client_eos", |     "camdetect_errors", | ||||||
|     "Count of End of Stream occurrences") |  | ||||||
| counter_connection_errors =  Counter( |  | ||||||
|     "camtiler_client_connection_errors", |  | ||||||
|     "Upstream connection errors", |     "Upstream connection errors", | ||||||
|     ["error"]) |     ["exception"]) | ||||||
| counter_movement_frames = Counter( | counter_movement_frames = Counter( | ||||||
|     "camtiler_client_movement_frames", |     "camdetect_movement_frames", | ||||||
|     "Frames with movement detected in them") |     "Frames with movement detected in them") | ||||||
|  |  | ||||||
| gauge_total_blocks = Gauge( | gauge_total_blocks = Gauge( | ||||||
|     "camtiler_client_total_blocks", |     "camdetect_total_blocks", | ||||||
|     "Total DCT blocks") |     "Total DCT blocks") | ||||||
| gauge_active_blocks = Gauge( | gauge_active_blocks = Gauge( | ||||||
|     "camtiler_client_active_blocks", |     "camdetect_active_blocks", | ||||||
|     "Total active, threshold exceeding DCT blocks") |     "Total active, threshold exceeding DCT blocks") | ||||||
|  |  | ||||||
| class Frame(object): | class Frame(object): | ||||||
| @@ -148,10 +145,11 @@ async def client(): | |||||||
|             try: |             try: | ||||||
|                 async with session.get(url) as resp: |                 async with session.get(url) as resp: | ||||||
|                     await client_connect(resp) |                     await client_connect(resp) | ||||||
|             except aiohttp.ClientConnectorError as e: |             except (aiohttp.ClientError, asyncio.exceptions.TimeoutError) as e: | ||||||
|                 counter_connection_errors.labels(error=e.strerror).inc() |                 j = "%s.%s" % (e.__class__.__module__, e.__class__.__name__) | ||||||
|             except asyncio.exceptions.TimeoutError: |                 print("Caught exception %s" % j) | ||||||
|                 counter_connection_errors.labels(error="Timeout").inc() |                 counter_errors.labels(exception=j).inc() | ||||||
|  |         await asyncio.sleep(1) | ||||||
|  |  | ||||||
|  |  | ||||||
| app = Sanic("lease") | app = Sanic("lease") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user