diff options
author | Kyomotoi <[email protected]> | 2022-06-18 00:24:53 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2022-06-18 00:24:53 +0800 |
commit | 6c02470858bf8e544d8655c039e741161c36ca54 (patch) | |
tree | dee0a9c8237c90241bc0cf686b93cea808f4980d /ATRI/plugins/setu/tf_dealer.py | |
parent | c1576c50f5acf1dd7f5d6730eae9d3d251fed954 (diff) | |
download | ATRI-6c02470858bf8e544d8655c039e741161c36ca54.tar.gz ATRI-6c02470858bf8e544d8655c039e741161c36ca54.tar.bz2 ATRI-6c02470858bf8e544d8655c039e741161c36ca54.zip |
🐛 解决无法正常终止程序
Diffstat (limited to 'ATRI/plugins/setu/tf_dealer.py')
-rw-r--r-- | ATRI/plugins/setu/tf_dealer.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/ATRI/plugins/setu/tf_dealer.py b/ATRI/plugins/setu/tf_dealer.py index 4e1eafa..466ab1f 100644 --- a/ATRI/plugins/setu/tf_dealer.py +++ b/ATRI/plugins/setu/tf_dealer.py @@ -1,6 +1,5 @@ import io import re -import asyncio import skimage import skimage.io import numpy as np @@ -48,7 +47,7 @@ def prepare_image(img): async def detect_image(url: str, file_size: int) -> list: try: req = await request.get(url) - except RequestError: + except Exception: raise RequestError("Get info from download image failed!") img_byte = getsizeof(req.read()) // 1024 @@ -61,7 +60,7 @@ async def detect_image(url: str, file_size: int) -> list: path = TEMP_PATH / f"{file_name}.jpg" with open(path, "wb") as f: f.write(req.read()) - except WriteFileError: + except Exception: raise WriteFileError("Writing file failed!") await init_module() @@ -110,7 +109,3 @@ async def init_module(): log.info("模型装载完成") except WriteFileError: raise WriteFileError("NSFW TF module init failed!") - - -loop = asyncio.get_event_loop() -loop.create_task(init_module()) |