File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -38,12 +38,15 @@ async def resolve_user(obj, info):
38
38
39
39
40
40
def test_execute_basic_async (benchmark ):
41
- try :
42
- run = asyncio .run
43
- except AttributeError : # Python < 3.7
44
- loop = asyncio .get_event_loop ()
45
- run = loop .run_until_complete # type: ignore
46
- result = benchmark (lambda : run (graphql (schema , "query { user { id, name }}" )))
41
+ # Note: we are creating the async loop outside of the benchmark code so that
42
+ # the setup is not included in the benchmark timings
43
+ loop = asyncio .events .new_event_loop ()
44
+ asyncio .events .set_event_loop (loop )
45
+ result = benchmark (
46
+ lambda : loop .run_until_complete (graphql (schema , "query { user { id, name }}" ))
47
+ )
48
+ asyncio .events .set_event_loop (None )
49
+ loop .close ()
47
50
assert not result .errors
48
51
assert result .data == {
49
52
"user" : {
You can’t perform that action at this time.
0 commit comments