We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2385f4f commit 94e50baCopy full SHA for 94e50ba
google/cloud/sql/connector/connector.py
@@ -281,6 +281,15 @@ async def connect_async(
281
KeyError: Unsupported database driver Must be one of pymysql, asyncpg,
282
pg8000, and pytds.
283
"""
284
+ # check if event loop is running in current thread
285
+ if self._loop != asyncio.get_running_loop():
286
+ raise ConnectorLoopError(
287
+ "Running event loop does not match 'connector._loop'. "
288
+ "Connector.connect_async() must be called from the event loop "
289
+ "the Connector was initialized with. If you need to connect "
290
+ "across event loops/threads please use a new Connector object."
291
+ )
292
+
293
if self._keys is None:
294
self._keys = asyncio.create_task(generate_keys())
295
if self._client is None:
0 commit comments