百度搜索完全搜不到类似的问题,中文的技术文章清一色的复制粘贴,只能看到loguru的介绍文章,只能到外网查查看。
git上看到有说是 monkey.patch_all() 的问题。
Hi. Problems of compatibility with
gevent
are not new, see #258.As the error message mentions
contextvars
, did you try callingmonkey.patch_all(contextvars=False)
instead?
然后有开发者回复了给参数加上 contextvars=False ,问题迎刃而解。
Another possibility is to import
loguru
after having calledmonkey.patch_all()
.For Python < 3.7, Loguru depends on the contextvars library which perform some sanity checks for types (which therefore is not the one expected if
ContextVar
is patched bygevent
).
另外有说先patch完再import loguru 包,也可以试一下看看。