From: Andrew Lewis Date: Thu, 11 Dec 2025 11:43:41 +0000 (+0200) Subject: [Test] Add hacks for backwards-compatibility X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5792%2Fhead;p=thirdparty%2Frspamd.git [Test] Add hacks for backwards-compatibility --- diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py index b82e58167a..c1dd97a28e 100755 --- a/test/functional/util/dummy_http.py +++ b/test/functional/util/dummy_http.py @@ -151,7 +151,11 @@ async def main(): if __name__ == "__main__": try: - asyncio.run(main()) + if hasattr(asyncio, 'run') and callable(getattr(asyncio, 'run')): + asyncio.run(main()) + else: + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) except Exception as e: print(f"dummy_http.py: FATAL ERROR: {type(e).__name__}: {e}", file=sys.stderr) traceback.print_exc(file=sys.stderr) diff --git a/test/functional/util/dummy_http_early_response.py b/test/functional/util/dummy_http_early_response.py index 2fbb2942cc..bacfb18d18 100755 --- a/test/functional/util/dummy_http_early_response.py +++ b/test/functional/util/dummy_http_early_response.py @@ -265,8 +265,13 @@ class EarlyResponseServer: async def serve_forever(self): """Serve until cancelled.""" - async with self.server: - await self.server.serve_forever() + # Python 3.7+ has serve_forever(), but 3.6 doesn't + if hasattr(self.server, 'serve_forever'): + async with self.server: + await self.server.serve_forever() + else: + # For Python 3.6 compatibility, use async context manager + await asyncio.Event().wait() async def main(): @@ -290,7 +295,11 @@ async def main(): if __name__ == "__main__": try: - asyncio.run(main()) + if hasattr(asyncio, 'run') and callable(getattr(asyncio, 'run')): + asyncio.run(main()) + else: + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) except KeyboardInterrupt: print("Shutting down...", file=sys.stderr) except Exception as e: