Commit 25a6f2db6684fad1b8f1d7868d744cc04dc90cdb

Authored by Miguel Barão
1 parent 5c8b68ea
Exists in dev

remove deprecated get_event_loop

perguntations/app.py
@@ -69,8 +69,7 @@ class App: @@ -69,8 +69,7 @@ class App:
69 self._make_test_factory(config["testfile"]) 69 self._make_test_factory(config["testfile"])
70 self._db_setup() # setup engine and load all students 70 self._db_setup() # setup engine and load all students
71 71
72 - # FIXME: get_event_loop will be deprecated in python3.  
73 - asyncio.get_event_loop().run_until_complete(self._assign_tests()) 72 + asyncio.run(self._assign_tests())
74 73
75 # command line options: --allow-all, --allow-list filename 74 # command line options: --allow-all, --allow-list filename
76 if config["allow_all"]: 75 if config["allow_all"]:
perguntations/testfactory.py
@@ -158,7 +158,7 @@ class TestFactory(dict): @@ -158,7 +158,7 @@ class TestFactory(dict):
158 if qmissing: 158 if qmissing:
159 raise TestFactoryException(f"Could not find questions {qmissing}.") 159 raise TestFactoryException(f"Could not find questions {qmissing}.")
160 160
161 - self.check_questions() 161 + asyncio.run(self.check_questions())
162 162
163 logger.info("Test factory ready. No errors found.") 163 logger.info("Test factory ready. No errors found.")
164 164
@@ -262,16 +262,14 @@ class TestFactory(dict): @@ -262,16 +262,14 @@ class TestFactory(dict):
262 # self.check_grade_scaling() 262 # self.check_grade_scaling()
263 263
264 # ------------------------------------------------------------------------ 264 # ------------------------------------------------------------------------
265 - def check_questions(self) -> None: 265 + async def check_questions(self) -> None:
266 """ 266 """
267 checks if questions can be correctly generated and corrected 267 checks if questions can be correctly generated and corrected
268 """ 268 """
269 logger.info("Checking questions...") 269 logger.info("Checking questions...")
270 - # FIXME: get_event_loop will be deprecated in python3.10  
271 - loop = asyncio.get_event_loop()  
272 for i, (qref, qfact) in enumerate(self["question_factory"].items()): 270 for i, (qref, qfact) in enumerate(self["question_factory"].items()):
273 try: 271 try:
274 - question = loop.run_until_complete(qfact.gen_async()) 272 + question = await qfact.gen_async()
275 except Exception as exc: 273 except Exception as exc:
276 msg = f'Failed to generate "{qref}"' 274 msg = f'Failed to generate "{qref}"'
277 raise TestFactoryException(msg) from exc 275 raise TestFactoryException(msg) from exc