You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2022/02/04 00:38:57 UTC

[incubator-ponymail-foal] 01/03: Temp testing hack

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 4a1eea66be0e2ea0e1a7c974f3296239ff7d7132
Author: Sebb <se...@apache.org>
AuthorDate: Fri Feb 4 00:36:48 2022 +0000

    Temp testing hack
---
 server/main.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/server/main.py b/server/main.py
index 3c804bd..5b1ae60 100644
--- a/server/main.py
+++ b/server/main.py
@@ -70,6 +70,7 @@ class Server(plugins.server.BaseServer):
         print(
             "==== Apache Pony Mail (Foal v/%s ~%s) starting... ====" % (PONYMAIL_FOAL_VERSION, PONYMAIL_SERVER_VERSION)
         )
+        self.args = args
         # Load configuration
         yml = yaml.safe_load(open(args.config))
         self.config = plugins.configuration.Configuration(yml)
@@ -243,11 +244,13 @@ class Server(plugins.server.BaseServer):
             await self.dbpool.get_nowait().client.close()
 
     def run(self):
+        if self.args.new_loop:
         # Does not work; GH test fails with: RuntimeError: Task .. got Future <Future pending> attached to a different loop
-        # loop = asyncio.new_event_loop()
-        # asyncio.set_event_loop(loop)
+            loop = asyncio.new_event_loop()
+            asyncio.set_event_loop(loop)
         # revert to original (deprecated) code
-        loop = asyncio.get_event_loop() # This needs to be replaced, as it will fail in Python 3.11
+        else:
+            loop = asyncio.get_event_loop() # This needs to be replaced, as it will fail in Python 3.11
         try:
             loop.run_until_complete(self.server_loop())
         except KeyboardInterrupt:
@@ -290,5 +293,11 @@ if __name__ == "__main__":
         action='store_true',
         help="Enable test endpoints",
     )
+    # temporary hack to allow testing alternate loop code on GH python versions
+    parser.add_argument(
+        "--new_loop",
+        action='store_true',
+        help="test new loop impl",
+    )
     cliargs = parser.parse_args()
     Server(cliargs).run()