From 7adef74fe9174693b741d61f54c38c3e197df942 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 19 Mar 2026 17:27:24 -0400 Subject: [PATCH] Delay async until after daemonize os.fork shouldn't happen after an async event loop if the child might use the async loop --- confluent_server/bin/confluent | 7 +++---- confluent_server/confluent/main.py | 7 +++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/confluent_server/bin/confluent b/confluent_server/bin/confluent index b5f56fe2..5eebfd75 100755 --- a/confluent_server/bin/confluent +++ b/confluent_server/bin/confluent @@ -15,7 +15,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import asyncio import sys import os @@ -35,12 +34,12 @@ import confluent.main #try: import multiprocessing -async def main(): - await confluent.main.run(sys.argv) +def main(): + confluent.main.run(sys.argv) if __name__ == '__main__': #multiprocessing.freeze_support() #asyncio.get_event_loop().run_until_complete(main()) - asyncio.run(main()) + main() #gt = spawn_for_awaitable(confluent.main.run(sys.argv)) #gt.wait() #except: diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index facb326f..bd8fea6b 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -276,8 +276,7 @@ def migrate_db(): configmanager.init() -async def run(args): - asyncio.get_event_loop().set_debug(True) +def run(args): setlimits() try: configmanager.ConfigManager(None) @@ -314,6 +313,10 @@ async def run(args): _redirectoutput() if havefcntl: _updatepidfile() + asyncio.run(asyncrun()) + +async def asyncrun(): + asyncio.get_event_loop().set_debug(True) signal.signal(signal.SIGINT, terminate) signal.signal(signal.SIGTERM, terminate) atexit.register(doexit)