Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > file locked for writing

Reply
Thread Tools

file locked for writing

 
 
Dmitry Teslenko
Guest
Posts: n/a
 
      05-13-2008
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any problems with writing the information into a file - Multi-users perform writing the same file at the same time ???? HNguyen ASP .Net 4 12-21-2004 01:53 PM
File locked by another process when cached with CacheDependency Keith ASP .Net 0 10-01-2003 09:29 PM
ldb file locked by aspnet_wp.exe MrB ASP .Net 1 09-15-2003 04:22 PM
A failure occurred writing to the resources file. Access is denied. -- RESX file is locked? -- WHY? Mark Kamoski ASP .Net 1 07-04-2003 12:02 PM



Advertisments