Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import os
  2. import fcntl
  3. import time
  4.  
  5. pid = os.getpid()
  6.  
  7. i = 10
  8. while i > 0:
  9. f = open('.locktest.lck')
  10. print '%s %d about to lock' % (time.time(), pid)
  11. rv = fcntl.lockf(f, fcntl.LOCK_EX)
  12. print '%s %d locked!' % (time.time(), pid)
  13. time.sleep(0.3)
  14. rv = fcntl.lockf(f, fcntl.LOCK_UN)
  15. print '%s %d unlocked' % (time.time(), os.getpid())
  16. time.sleep(0.1)
  17. i = i - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement