Skip to content

Commit ee7b621

Browse files
committed
make client knobs support async
1 parent 590274f commit ee7b621

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/helpers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import traceback
2929
import unittest
3030
import warnings
31+
from asyncio import iscoroutinefunction
3132

3233
try:
3334
import ipaddress
@@ -204,10 +205,18 @@ def __exit__(self, exc_type, exc_val, exc_tb):
204205

205206
def __call__(self, func):
206207
def make_wrapper(f):
208+
if iscoroutinefunction(f):
209+
wraps_async = True
210+
else:
211+
wraps_async = False
212+
207213
@wraps(f)
208-
def wrap(*args, **kwargs):
214+
async def wrap(*args, **kwargs):
209215
with self:
210-
return f(*args, **kwargs)
216+
if wraps_async:
217+
return await f(*args, **kwargs)
218+
else:
219+
return f(*args, **kwargs)
211220

212221
return wrap
213222

0 commit comments

Comments
 (0)