@@ -143,19 +143,8 @@ class Instance:
143143 Enables automatic IAM database authentication for Postgres or MySQL
144144 instances.
145145 :type enable_iam_auth: bool
146-
147- :param loop:
148- A new event loop for the refresh function to run in.
149- :type loop: asyncio.AbstractEventLoop
150146 """
151147
152- # asyncio.AbstractEventLoop is used because the default loop,
153- # SelectorEventLoop, is usable on both Unix and Windows but has limited
154- # functionality on Windows. It is recommended to use ProactorEventLoop
155- # while developing on Windows.
156- # Link to Github issue:
157- # https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/issues/22
158- _loop : asyncio .AbstractEventLoop
159148 _enable_iam_auth : bool
160149 _keys : asyncio .Future
161150 _instance_connection_string : str
@@ -173,7 +162,6 @@ def __init__(
173162 instance_connection_string : str ,
174163 client : CloudSQLClient ,
175164 keys : asyncio .Future ,
176- loop : asyncio .AbstractEventLoop ,
177165 enable_iam_auth : bool = False ,
178166 ) -> None :
179167 # validate and parse instance connection name
@@ -183,11 +171,11 @@ def __init__(
183171 self ._instance_connection_string = instance_connection_string
184172
185173 self ._enable_iam_auth = enable_iam_auth
186- self ._loop = loop
187174 self ._keys = keys
188175 self ._client = client
189176 self ._refresh_rate_limiter = AsyncRateLimiter (
190- max_capacity = 2 , rate = 1 / 30 , loop = self ._loop
177+ max_capacity = 2 ,
178+ rate = 1 / 30 ,
191179 )
192180 self ._refresh_in_progress = asyncio .locks .Event ()
193181 self ._current = self ._schedule_refresh (0 )
@@ -225,15 +213,15 @@ async def _perform_refresh(self) -> ConnectionInfo:
225213
226214 logger .debug (f"['{ self ._instance_connection_string } ']: Creating context" )
227215
228- metadata_task = self . _loop .create_task (
216+ metadata_task = asyncio .create_task (
229217 self ._client ._get_metadata (
230218 self ._project ,
231219 self ._region ,
232220 self ._instance ,
233221 )
234222 )
235223
236- ephemeral_task = self . _loop .create_task (
224+ ephemeral_task = asyncio .create_task (
237225 self ._client ._get_ephemeral (
238226 self ._project ,
239227 self ._instance ,
@@ -306,7 +294,7 @@ async def _refresh_task(self: Instance, delay: int) -> ConnectionInfo:
306294 logger .debug (f"['{ self ._instance_connection_string } ']: Entering sleep" )
307295 if delay > 0 :
308296 await asyncio .sleep (delay )
309- refresh_task = self . _loop .create_task (self ._perform_refresh ())
297+ refresh_task = asyncio .create_task (self ._perform_refresh ())
310298 refresh_data = await refresh_task
311299 except asyncio .CancelledError :
312300 logger .debug (
@@ -337,7 +325,7 @@ async def _refresh_task(self: Instance, delay: int) -> ConnectionInfo:
337325 return refresh_data
338326
339327 # schedule refresh task and return it
340- scheduled_task = self . _loop .create_task (_refresh_task (self , delay ))
328+ scheduled_task = asyncio .create_task (_refresh_task (self , delay ))
341329 return scheduled_task
342330
343331 async def connect_info (
0 commit comments