()
| 58 | |
| 59 | |
| 60 | def test_concurrent_lock(): |
| 61 | filename = 'thread.lock' |
| 62 | |
| 63 | def lock(): |
| 64 | lock = library.python.filelock.FileLock(filename) |
| 65 | time.sleep(1) |
| 66 | assert lock.acquire() |
| 67 | lock.release() |
| 68 | try: |
| 69 | os.unlink(filename) |
| 70 | except OSError: |
| 71 | pass |
| 72 | |
| 73 | threads = [] |
| 74 | for i in range(100): |
| 75 | t = threading.Thread(target=lock) |
| 76 | threads.append(t) |
| 77 | |
| 78 | for t in threads: |
| 79 | t.start() |
| 80 | |
| 81 | for t in threads: |
| 82 | t.join() |
| 83 | |
| 84 | |
| 85 | def test_pidfilelock(): |