@@ -144,8 +144,8 @@ def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: Tes
144
144
continue
145
145
146
146
loop = asyncio .get_event_loop ()
147
- result = loop .run_until_complete (asyncio . wait_for (
148
- self ._run (parser , runner_config ), parser . timeout ))
147
+ result = loop .run_until_complete (
148
+ self ._run_with_timeout (parser , runner_config ))
149
149
if isinstance (result , Exception ):
150
150
raise (result )
151
151
elif not result :
@@ -157,11 +157,20 @@ def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: Tes
157
157
158
158
return parser_builder .done
159
159
160
- async def _run (self , parser : TestParser , config : TestRunnerConfig ):
160
+ async def _run_with_timeout (self , parser : TestParser , config : TestRunnerConfig ):
161
161
status = True
162
162
try :
163
163
await self .start ()
164
+ status = await asyncio .wait_for (self ._run (parser , config ), parser .timeout )
165
+ except Exception as exception :
166
+ status = exception
167
+ finally :
168
+ await self .stop ()
169
+ return status
164
170
171
+ async def _run (self , parser : TestParser , config : TestRunnerConfig ):
172
+ status = True
173
+ try :
165
174
hooks = config .hooks
166
175
hooks .test_start (parser .filename , parser .name , parser .tests .count )
167
176
@@ -214,5 +223,4 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig):
214
223
except Exception as exception :
215
224
status = exception
216
225
finally :
217
- await self .stop ()
218
226
return status
0 commit comments