Add SRR file locking

Issue #73 closed
Gfy repo owner created an issue

Add file locking when writing a .srr file.

"Duplicate file detected! " will show up on srrdb.com for all files when two different processes try to create the same .srr file at the same time.

This occurs with music releases.

Comments (4)

  1. Gfy reporter
    • removed responsible

    Just adding cross platform locking doesn't seem easy and seems error prone: http://stackoverflow.com/questions/489861/locking-a-file-in-python

    An easier approach seems to be to create the new .srr as a temporary file and to overwrite the existing file with that. It'll contain only the data of the process that finishes last.

    This could also improve the handling of incomplete files in a more proper way.

  2. Gfy reporter

    Windows .bat script to test this:

    ECHO Testing simultanious music .srr creation
    START "First process" pyrescene -y .
    START "Second process" pyrescene -y .
    

    There is also a good chance this error can be seen:

    [Error 183] Kan geen bestand maken dat al bestaat
    Traceback (most recent call last):
      File "bin\windows\..\pyrescene.py", line 1295, in <module>
        sys.exit(main())
      File "bin\windows\..\pyrescene.py", line 1206, in main
        result = generate_srr(reldir, working_dir, options, mthread)
      File "bin\windows\..\pyrescene.py", line 643, in generate_srr
        rescene.remove_stored_files(srr, rescene.info(srr)["stored_files"])
      File "rescene\main.py", line 362, in remove_stored_files
        os.rename(tmpname, srr_file)
    WindowsError: [Error 183] Kan geen bestand maken dat al bestaat
    

    Should also be handled properly.

  3. Log in to comment