mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	memcached_exporter: Explicitly close memcached connection.
Fixes warnings like “ResourceWarning: unclosed <socket.socket fd=5,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0,
laddr=('127.0.0.1', 39702), raddr=('127.0.0.1', 11211)>” with warnings
enabled.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
			
			
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							c8eaceff21
						
					
				
				
					commit
					f3c67103cf
				
			@@ -382,12 +382,13 @@ class MemcachedCollector(Collector):
 | 
			
		||||
 | 
			
		||||
        raw_stats = client.stats("sizes")
 | 
			
		||||
        sizes_stats = next(iter(raw_stats.values()))
 | 
			
		||||
        if sizes_stats.get("sizes_status") == b"disabled" or sizes_stats == {}:
 | 
			
		||||
            return
 | 
			
		||||
        sizes = sorted([int(x) for x in sizes_stats])
 | 
			
		||||
        yield gauge(
 | 
			
		||||
            "item_max_bytes", "Largest item (rounded to 32 bytes) in bytes.", value=sizes[-1]
 | 
			
		||||
        )
 | 
			
		||||
        if sizes_stats.get("sizes_status") != b"disabled" and sizes_stats != {}:
 | 
			
		||||
            sizes = sorted([int(x) for x in sizes_stats])
 | 
			
		||||
            yield gauge(
 | 
			
		||||
                "item_max_bytes", "Largest item (rounded to 32 bytes) in bytes.", value=sizes[-1]
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        client.disconnect_all()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user