Re: file locked for writing



En Tue, 13 May 2008 11:57:03 -0300, Dmitry Teslenko <dteslenko@xxxxxxxxx> escribió:

Hello!
I use some script in python 2.5 from vim editor (it has python
bindings) that updates some file
and then launches another program (ms visual studio, for example) to
do something with updated file.
I faced problem when updated file is locked for writing until vim
editor is closed.

launch vim -> update file -> launch msvc -> file locked
launch vim -> update file -> launch msvc -> close vim -> file locked
launch vim -> update file -> -> close vim -> launch msvc -> file okay

Update code is something like that:

backup_file_name = '<some file name>'
with open(backup_file_name, 'w') as backup_file:
input = sax.make_parser()
output = saxutils.XMLGenerator(backup_file, 'cp1252')
filter = __vcproj_config_filter('<updated file name>', input, output)
filter.parse('<updated file name>')
shutil.copyfile(backup_file_name, '<updated file name>')
os.remove(backup_file_name)

__vcproj_config_filter is a descent of a XMLFilterBase; it substitutes
some attributes in xml file and that's all.
must be noted that __vcproj_config_filter instance holds reference to
output (sax xml parser) object.

Is the code above contained in a function? So all references are released upon function exit?
If not, you could try using: del input, output, filter
That should release all remaining references to the output file, I presume. Or locate the inner reference to the output file (filter.something perhaps?) and explicitely close it.

--
Gabriel Genellina

.



Relevant Pages

  • file locked for writing
    ... I use some script in python 2.5 from vim editor (it has python ... bindings) that updates some file ... output (sax xml parser) object. ...
    (comp.lang.python)
  • Re: Yum problem after update on FC-3
    ... There is not other way to get python 2.4 than to get it by the ... > including updates of yum and python. ... What is the output of "rpm -q fedora-release"? ... getting the package from the development ...
    (Fedora)
  • Re: EPD 7.0 released
    ... I am pleased to announce that EPD (Enthought Python Distribution) ... addition to updates to many of the other packages included. ... Additional support options, including ...
    (comp.lang.python)
  • Re: Web update library in python?
    ... Concering 'egg' it's not a web update for python ... I want to provide my users the ability to download a repository from ... and after that check for updates. ... and let the patch be applied locally. ...
    (comp.lang.python)
  • ANN: EPD 6.2 released
    ... I am pleased to announce that EPD (Enthought Python Distribution) ... Python 2.6.5, SciPy 0.8.0beta1, as well updates to many other ... The EPD bundle includes NumPy, SciPy, ...
    (comp.lang.python.announce)