feat: 彻底移除 yirimirai

This commit is contained in:
Junyan Qin
2024-11-15 20:03:49 +08:00
parent 16153dc573
commit 3239c9ec3f
9 changed files with 21 additions and 169 deletions

View File

@@ -125,3 +125,10 @@ class Application:
except Exception as e:
self.logger.error(f"应用运行致命异常: {e}")
self.logger.debug(f"Traceback: {traceback.format_exc()}")
async def scoped_shutdown(self, scopes: list[str]):
pass
async def shutdown(self):
for task in self.task_mgr.tasks:
task.cancel()

View File

@@ -53,13 +53,17 @@ async def main(loop: asyncio.AbstractEventLoop):
# 挂系统信号处理
import signal
ap: app.Application
def signal_handler(sig, frame):
print("[Signal] 程序退出.")
# ap.shutdown()
os._exit(0)
signal.signal(signal.SIGINT, signal_handler)
app_inst = await make_app(loop)
ap = app_inst
await app_inst.run()
except Exception as e:
traceback.print_exc()

View File

@@ -154,6 +154,9 @@ class TaskWrapper:
"result": self.assume_result().__str__() if self.assume_result() is not None else None,
},
}
def cancel(self):
self.task.cancel()
class AsyncTaskManager: