Skip to content

Commit be55d5d

Browse files
committed
pool: Make sure PoolConnectionProxy metaclass proxies only methods
1 parent d1ee90e commit be55d5d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

asyncpg/pool.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import asyncio
99
import functools
10+
import inspect
1011

1112
from . import connection
1213
from . import exceptions
@@ -16,20 +17,23 @@ class PoolConnectionProxyMeta(type):
1617

1718
def __new__(mcls, name, bases, dct, *, wrap=False):
1819
if wrap:
19-
def get_wrapper(methname):
20-
meth = getattr(connection.Connection, methname)
21-
20+
def get_wrapper(meth):
2221
def wrapper(self, *args, **kwargs):
2322
return self._dispatch_method_call(meth, args, kwargs)
24-
2523
return wrapper
2624

2725
for attrname in dir(connection.Connection):
2826
if attrname.startswith('_') or attrname in dct:
2927
continue
30-
wrapper = get_wrapper(attrname)
28+
29+
meth = getattr(connection.Connection, attrname)
30+
if not inspect.isfunction(meth):
31+
continue
32+
33+
wrapper = get_wrapper(meth)
3134
wrapper = functools.update_wrapper(
3235
wrapper, getattr(connection.Connection, attrname))
36+
3337
dct[attrname] = wrapper
3438

3539
if '__doc__' not in dct:

0 commit comments

Comments
 (0)