初始化项目,由ModelHub XC社区提供模型

Model: ayh015/myLightningOPD
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-08-27 23:50:14 +08:00
commit d4e0a1af66
368 changed files with 559583 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import asyncio
import threading
__all__ = ["get_async_loop", "run"]
# Create a background event loop thread
class AsyncLoopThread:
def __init__(self):
self.loop = asyncio.new_event_loop()
self._thread = threading.Thread(target=self._start_loop, daemon=True)
self._thread.start()
def _start_loop(self):
asyncio.set_event_loop(self.loop)
self.loop.run_forever()
def run(self, coro):
# Schedule a coroutine onto the loop and block until it's done
return asyncio.run_coroutine_threadsafe(coro, self.loop).result()
# Create one global instance
async_loop = None
def get_async_loop():
global async_loop
if async_loop is None:
async_loop = AsyncLoopThread()
return async_loop
def run(coro):
"""Run a coroutine in the background event loop."""
return get_async_loop().run(coro)