ajack       2004/04/20 15:53:26

  Modified:    .        gumpy.py
  Log:
  Hmm, seems I can delete a file from the file system even though it

  is locked. I found then when running N at once (they all blocked).

  

  [I assume I just remove inode reference from dir, but 

  makes creating a new gumpy.lock and locking that somewhat pointless.]

  

  So, make the first test non-blocking.

  
  Revision  Changes    Path
  1.20      +8 -6      gump/gumpy.py
  
  Index: gumpy.py
  ===================================================================
  RCS file: /home/cvs/gump/gumpy.py,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- gumpy.py  20 Apr 2004 21:18:02 -0000      1.19
  +++ gumpy.py  20 Apr 2004 22:53:26 -0000      1.20
  @@ -139,7 +139,7 @@
                   

           try:            

               lock=open(lockFile,'a+')

  -            fcntl.flock(lock.fileno(), fcntl.LOCK_EX)

  +            fcntl.flock(lock.fileno(), fcntl.LOCK_EX | fnctl.LOCK_NB)

           except:

               failed=1

           

  @@ -175,11 +175,13 @@
       # Close it, so we can dispose of it

       lock.close()    

       

  -    # :TODO: We have issues when python is killed, we get a lock

  -    # left around despite this finally.

  -    os.remove(lockFile)

  -

  -

  +    # Others might be blocked on this

  +    try:

  +        os.remove(lockFile)

  +    except:

  +        # Somehow another could delete this, even if locked...

  +        pass

  +                

   # Allow a lock    

   lockFile=os.path.abspath('gumpy.lock')

   lock=establishLock(lockFile)        

  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to