Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在文件 a.py 中,我有以下几行:
import gevent gevent.monkey.patch_all() import b # etc, etc
在文件 b.py 中是否有必要再次进行猴子补丁?猴子补丁多次有什么问题吗?
通常每个模块只有一个条目sys.modules。也就是说,同一个模块对象是共享的,所以只要它以相同的方式导入,它就会影响模块。
sys.modules
sys.modules如果导入方式不同,则可能在两个或多个条目中包含相同的模块。