@@ -227,15 +227,15 @@ def _classify_servers_from_pool(self, pool: MCPSessionPool, all_gateway_urls: Li
227227 Returns:
228228 ClassificationResult with hot/cold servers and metadata
229229 """
230- N = len (all_gateway_urls )
231- hot_cap = floor (0.20 * N )
230+ total_servers = len (all_gateway_urls )
231+ hot_cap = floor (0.20 * total_servers )
232232
233233 # Step 3: Extract server usage from pooled sessions
234234 server_metrics : Dict [str , ServerUsageMetrics ] = {}
235235
236236 # Iterate over pool._pools (Dict[PoolKey, Queue[PooledSession]])
237237 # PoolKey = (user_identity, url, identity_hash, transport_type, gateway_id)
238- for pool_key , session_queue in pool ._pools .items ():
238+ for pool_key , session_queue in pool ._pools .items (): # pylint: disable=protected-access
239239 url = pool_key [1 ] # Extract server URL from pool key
240240
241241 if url not in server_metrics :
@@ -244,7 +244,7 @@ def _classify_servers_from_pool(self, pool: MCPSessionPool, all_gateway_urls: Li
244244 # Process each pooled session in the queue
245245 try :
246246 # Access queue items (asyncio.Queue has internal _queue deque)
247- sessions_list = list (session_queue ._queue ) if hasattr (session_queue , "_queue" ) else []
247+ sessions_list = list (session_queue ._queue ) if hasattr (session_queue , "_queue" ) else [] # pylint: disable=protected-access
248248
249249 for session in sessions_list :
250250 # PooledSession has: last_used, use_count
@@ -258,7 +258,7 @@ def _classify_servers_from_pool(self, pool: MCPSessionPool, all_gateway_urls: Li
258258 continue
259259
260260 # Count active sessions from _active dict
261- for pool_key , active_set in pool ._active .items ():
261+ for pool_key , active_set in pool ._active .items (): # pylint: disable=protected-access
262262 url = pool_key [1 ]
263263 if url in server_metrics :
264264 server_metrics [url ].active_session_count += len (active_set )
@@ -293,7 +293,7 @@ def _classify_servers_from_pool(self, pool: MCPSessionPool, all_gateway_urls: Li
293293 return ClassificationResult (
294294 hot_servers = hot_servers ,
295295 cold_servers = cold_servers ,
296- metadata = ClassificationMetadata (N = N , hot_cap = hot_cap , hot_actual = hot_actual , eligible_count = eligible_count , timestamp = time .time (), underutilized_reason = underutilized_reason ),
296+ metadata = ClassificationMetadata (N = total_servers , hot_cap = hot_cap , hot_actual = hot_actual , eligible_count = eligible_count , timestamp = time .time (), underutilized_reason = underutilized_reason ),
297297 )
298298
299299 async def _get_all_gateway_urls (self ) -> List [str ]:
@@ -306,11 +306,11 @@ async def _get_all_gateway_urls(self) -> List[str]:
306306 from sqlalchemy import select
307307
308308 # First-Party
309- from mcpgateway .db import DbGateway , SessionLocal
309+ from mcpgateway .db import Gateway , SessionLocal
310310
311311 try :
312312 with SessionLocal () as db :
313- result = db .execute (select (DbGateway .url ).where (DbGateway .enabled == True )) # noqa: E712
313+ result = db .execute (select (Gateway .url ).where (Gateway .enabled is True ))
314314 urls = [row [0 ] for row in result ]
315315 return urls
316316 except Exception as e :
0 commit comments