- 主题:asyncio里logging和print失效?
class process_helper(process_helper_interface):
def __init__(self):
self.logger = logging.getLogger(__name__)
async def info(self, message):
self.logger.info(message)
class xxxx:
async def get_file_md5_by_chunk(self, file_path: str, chunk_size=65536):
async with aiofiles.open(file_path, "rb") as fp:
while True:
chunk = await fp.read(chunk_size)
if not chunk:
break
await self.set_info(file_path)
yield hashlib.md5(chunk).hexdigest()
设成printf,加上async/await还是去掉,日志信息都不显示
这是咋回事
--
修改:iwannabe FROM 119.139.197.*
FROM 119.139.197.*
会不会是因为你的 logger 没有配置好?
没有设置打印到控制台?或者 log 级别不够?
【 在 iwannabe 的大作中提到: 】
: class process_helper(process_helper_interface):
: def __init__(self):
: self.logger = logging.getLogger(__name__)
: ...................
--
FROM 124.72.110.*
asyncio.run之前logging没问题
【 在 hgoldfish 的大作中提到: 】
: 会不会是因为你的 logger 没有配置好?
: 没有设置打印到控制台?或者 log 级别不够?
--
FROM 120.229.207.*
你的代码里压根没有调用info啊
【 在 iwannabe (I wanna be) 的大作中提到: 】
: 发信人: iwannabe (I wanna be), 信区: Python
: 标 题: asyncio里logging和print失效?
: 发信站: 水木社区 (Tue May 16 17:27:00 2023), 转信
:
--
FROM 183.179.53.*