]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Add hacks for backwards-compatibility 5792/head
authorAndrew Lewis <nerf@judo.za.org>
Thu, 11 Dec 2025 11:43:41 +0000 (13:43 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Thu, 11 Dec 2025 14:04:42 +0000 (16:04 +0200)
test/functional/util/dummy_http.py
test/functional/util/dummy_http_early_response.py

index b82e58167ad3e516d0d03a1a6bbf423b749ea4a5..c1dd97a28e28043ac569327a5b4857f36c582246 100755 (executable)
@@ -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)
index 2fbb2942cc17a8f30579869d34802a78199c3681..bacfb18d1812cbed421380b1d99e16cf4080da70 100755 (executable)
@@ -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: