Python Forum

Full Version: Accessing same python script from multiple computers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I currently work in a facility that uses a very large ZFS using the NFS protocol. We have many servers that are running a variety of Linux distribution. I am setting up a folder to store python scripts for other people to use on any one of our servers. I realize the python does this compiling on runtime. And I think it saves the compiled version in __pycache__. This leads me to believe that this can be in issue if different servers with different operating systems are accessing the same file. Is this going to be an issue or should a have a duplicate folder for each operating system?
As far as I know, the __pycache__ mechanism is used for imported modules, not for scripts executed as main programs.

If nothing else works, starting with Python 3.8, you can perhaps set the sys.pycache_prefix on each server, for example in the sitecustomize.py file. Thus each server could define where it wants to store its cached python modules.

Python stores bytecode-compiled modules in the __pycache__ directory. Bytecode depends on the version of Python used, but the mechanism adds a suffix to the module names to distinguish the different versions, for example on my system, if I have a module spam.py, it writes spam.cpython-38.pyc in the pycache directory. This makes me believe that it should not be an issue and you should try to share the cache before attempting something else.