File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -46,26 +46,27 @@ def close(self):
46
46
if self ._loop is None :
47
47
return
48
48
try :
49
- _cancel_all_tasks (self ._loop )
50
- self ._loop .run_until_complete (self ._loop .shutdown_asyncgens ())
51
- self ._loop .run_until_complete (self ._loop .shutdown_default_executor ())
49
+ loop = self ._loop
50
+ _cancel_all_tasks (loop )
51
+ loop .run_until_complete (loop .shutdown_asyncgens ())
52
+ loop .run_until_complete (loop .shutdown_default_executor ())
52
53
finally :
53
- self . _loop .close ()
54
+ loop .close ()
54
55
self ._loop = None
55
56
56
- def run (self , coro ):
57
+ def run (self , coro , * , context = None ):
57
58
"""Run a coroutine inside the embedded event loop."""
58
59
if not coroutines .iscoroutine (coro ):
59
60
raise ValueError ("a coroutine was expected, got {!r}" .format (coro ))
60
61
61
- return self ._loop .run_until_complete (coro )
62
+ task = self ._loop .create_task (coro , context = context )
63
+ return self ._loop .run_until_complete (task )
62
64
63
65
def get_loop (self ):
64
66
"""Returnb embedded event loop."""
65
67
return self ._loop
66
68
67
69
68
-
69
70
def run (main , * , debug = None ):
70
71
"""Execute the coroutine and return the result.
71
72
You can’t perform that action at this time.
0 commit comments