469,658 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

Re: file locked for writing

En Tue, 13 May 2008 11:57:03 -0300, Dmitry Teslenko <dt*******@gmail.com>
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>')

__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

Jun 27 '08 #1
0 1294

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Pekka Niiranen | last post: by
2 posts views Thread by Basti | last post: by
5 posts views Thread by Fabio R. | last post: by
8 posts views Thread by darrel | last post: by
6 posts views Thread by Moumen VB.NET 2003/2005 Developer | last post: by
6 posts views Thread by tomtown.net | last post: by
reply views Thread by Dmitry Teslenko | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.