@@ -143,19 +143,8 @@ class Instance:
143
143
Enables automatic IAM database authentication for Postgres or MySQL
144
144
instances.
145
145
: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
150
146
"""
151
147
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
159
148
_enable_iam_auth : bool
160
149
_keys : asyncio .Future
161
150
_instance_connection_string : str
@@ -173,7 +162,6 @@ def __init__(
173
162
instance_connection_string : str ,
174
163
client : CloudSQLClient ,
175
164
keys : asyncio .Future ,
176
- loop : asyncio .AbstractEventLoop ,
177
165
enable_iam_auth : bool = False ,
178
166
) -> None :
179
167
# validate and parse instance connection name
@@ -183,11 +171,11 @@ def __init__(
183
171
self ._instance_connection_string = instance_connection_string
184
172
185
173
self ._enable_iam_auth = enable_iam_auth
186
- self ._loop = loop
187
174
self ._keys = keys
188
175
self ._client = client
189
176
self ._refresh_rate_limiter = AsyncRateLimiter (
190
- max_capacity = 2 , rate = 1 / 30 , loop = self ._loop
177
+ max_capacity = 2 ,
178
+ rate = 1 / 30 ,
191
179
)
192
180
self ._refresh_in_progress = asyncio .locks .Event ()
193
181
self ._current = self ._schedule_refresh (0 )
@@ -225,15 +213,15 @@ async def _perform_refresh(self) -> ConnectionInfo:
225
213
226
214
logger .debug (f"['{ self ._instance_connection_string } ']: Creating context" )
227
215
228
- metadata_task = self . _loop .create_task (
216
+ metadata_task = asyncio .create_task (
229
217
self ._client ._get_metadata (
230
218
self ._project ,
231
219
self ._region ,
232
220
self ._instance ,
233
221
)
234
222
)
235
223
236
- ephemeral_task = self . _loop .create_task (
224
+ ephemeral_task = asyncio .create_task (
237
225
self ._client ._get_ephemeral (
238
226
self ._project ,
239
227
self ._instance ,
@@ -306,7 +294,7 @@ async def _refresh_task(self: Instance, delay: int) -> ConnectionInfo:
306
294
logger .debug (f"['{ self ._instance_connection_string } ']: Entering sleep" )
307
295
if delay > 0 :
308
296
await asyncio .sleep (delay )
309
- refresh_task = self . _loop .create_task (self ._perform_refresh ())
297
+ refresh_task = asyncio .create_task (self ._perform_refresh ())
310
298
refresh_data = await refresh_task
311
299
except asyncio .CancelledError :
312
300
logger .debug (
@@ -337,7 +325,7 @@ async def _refresh_task(self: Instance, delay: int) -> ConnectionInfo:
337
325
return refresh_data
338
326
339
327
# 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 ))
341
329
return scheduled_task
342
330
343
331
async def connect_info (
0 commit comments