Odd delays when cwd is on a network mount

Tobiah toby at tobiah.org
Fri Oct 11 14:06:26 EDT 2019


On 10/11/19 10:56 AM, Tobiah wrote:
> I have a directory mounted with sshfs over a 5mb connection.
> It's quite usable under most circumstances.
> 
> When I run python from a directory under that mount, imports from local
> directories are quite slow:
> 
> $ python2.7
>>>> import my_module  ##  takes 25 seconds to complete
>>>> my_module.__file__
>>>> /local/dir/not/on/mount/my_module.py
> 
> When I do the same thing from my home directory
> there is no delay.
> 
> $ wc -l /local/dir/not/on/mount/my_module.py
> 156 /local/dir/not/on/mount/my_module.py
> 
> Thanks for any help.
> 
> 
> Tobiah
> 
> 
> 

Another way:

$ cd ~
$ python2.7
>>> import os
>>> os.chdir('/remote/mount/point')
>>> import my_module	## 25 seconds again
>>>> my_module.__file__
>>>> /local/dir/not/on/mount/my_module.py


Without the os.chdir() the import is instantaneous.




More information about the Python-list mailing list