open-iscsi / configshell-fb

configshell with additional modifications, see README
Apache License 2.0
28 stars 37 forks source link

Acquire a lock to a preference file before working with it #43

Closed avagin closed 6 years ago

avagin commented 6 years ago

Otherwise we can meet a situation, when one process is writing a file, but another process tries to read the same file:

prefs.py:147:load:EOFError

Traceback (most recent call last): File "/usr/bin/targetcli", line 121, in main() File "/usr/bin/targetcli", line 77, in main shell = TargetCLI('~/.targetcli') File "/usr/lib/python2.7/site-packages/configshell_fb/shell.py", line 176, in init self.prefs.load() File "/usr/lib/python2.7/site-packages/configshell_fb/prefs.py", line 147, in load self._prefs = six.moves.cPickle.load(fsock) EOFError

Local variables in innermost frame: self: <configshell_fb.prefs.Prefs object at 0x1077550> fsock: <closed file '/root/.targetcli/prefs.bin', mode 'rb' at 0x1058300> filename: '/root/.targetcli/prefs.bin'

agrover commented 6 years ago

looks good! Thanks for making configshell better!