[Serve] Call without loop parameter if python 3.10+ (#19298)

This commit is contained in:
Carlo Grisetti 2021-10-12 03:31:13 +02:00 committed by GitHub
parent 6cacc54774
commit c2377fb725
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,4 @@
import sys
import asyncio
import pickle
import itertools
@ -66,7 +67,14 @@ class ReplicaSet:
# Used to unblock this replica set waiting for free replicas. A newly
# added replica or updated max_concurrent_queries value means the
# query that waits on a free replica might be unblocked on.
self.config_updated_event = asyncio.Event(loop=event_loop)
# Python 3.8 has deprecated the 'loop' parameter, and Python 3.10 has
# removed it alltogether. Call accordingly.
if sys.version_info.major >= 3 and sys.version_info.minor >= 10:
self.config_updated_event = asyncio.Event()
else:
self.config_updated_event = asyncio.Event(loop=event_loop)
self.num_queued_queries = 0
self.num_queued_queries_gauge = metrics.Gauge(
"serve_deployment_queued_queries",