side effect after importing containers
Opened this issue · 1 comments
Hello,
one of our software uses dependency injector library in its core. I have noticed an unexpected side effect on Win11. The script that uses dependency injector is in a zip file. After executing the line in which containers is imported, it is not possible to modify the zip file anymore. On Win10 there is not such an effect. I could only test it on 2 machines. There is a minimal example below.
Python version: 3.11.9
dependency injector version: 4.48.1
File Structure
main.py
foo.zip/
├─ foo.py
# foo.py
import os
from dependency_injector import containers# main.py
import sys
from time import sleep
sys.path.insert(0, "foo.zip")
import foo
while True:
sleep(1)Are you modifying foo.zip at runtime and then trying to import something out of it? If so, I do not think this is something you should normally do. This issue does not look like it's specific to Windows nor DI. Python caches modules on import, so you might try doing importlib.invalidate_caches() and/or importlib.reload(foo). If this does not solve your problem, please provide more details how exactly you're modifying the file and steps to verify difference in behavior between OS versions.