Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note which kwargs are safe to pass to Pool.set_connect_args #439

Open
adamrothman opened this issue May 7, 2019 · 0 comments
Open

Note which kwargs are safe to pass to Pool.set_connect_args #439

adamrothman opened this issue May 7, 2019 · 0 comments

Comments

@adamrothman
Copy link

@adamrothman adamrothman commented May 7, 2019

The documentation for asyncpg.pool.Pool.set_connect_args makes no mention that there are 2 particular kwargs that are already being passed to connect by the pool when it creates new connections:

asyncpg/asyncpg/pool.py

Lines 459 to 463 in 92c2d81

con = await connection.connect(
*self._connect_args,
loop=self._loop,
connection_class=self._connection_class,
**self._connect_kwargs)

Before reading the source, I incorrectly assumed that any of connect's kwargs are safe to pass to Pool.set_connect_args, but if you pass either loop or connection_class you'll end up with a traceback like this:

Traceback (most recent call last):
... omitted for brevity ...
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 762, in __aenter__
self.connection = await self.pool._acquire(self.timeout)
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 604, in _acquire
return await _acquire_impl()
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 589, in _acquire_impl
proxy = await ch.acquire() # type: PoolConnectionProxy
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 133, in acquire
await self.connect()
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 125, in connect
self._con = await self._pool._get_new_connection()
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 463, in _get_new_connection
**self._connect_kwargs)
TypeError: connect() got multiple values for keyword argument 'loop'

Not hard to fix in my app, but it'd be great to update the docs to maybe save future users some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.