file locked for writing

Discussion in 'Python' started by Dmitry Teslenko, May 13, 2008.

  1. 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.
     
    Dmitry Teslenko, May 13, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    1
    Views:
    2,456
  2. MrB
    Replies:
    1
    Views:
    2,196
  3. Keith
    Replies:
    0
    Views:
    537
    Keith
    Oct 1, 2003
  4. hkappleorange

    database file locked by aspx

    hkappleorange, Nov 6, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    1,737
  5. mishi_math
    Replies:
    11
    Views:
    15,641
    mishi_math
    Aug 26, 2003
Loading...

Share This Page