blob: 7c075ae9811c13a4dd3d0d0406e79a14f1be833f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
diff --git a/xcffib/testing.py b/xcffib/testing.py
index ef0268a..0662fcf 100644
--- a/xcffib/testing.py
+++ b/xcffib/testing.py
@@ -31,11 +31,14 @@ def lock_path(display):
def find_display():
display = 10
while True:
- f = open(lock_path(display), "w+")
try:
- fcntl.flock(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
- except OSError:
- f.close()
+ f = open(lock_path(display), "w+")
+ try:
+ fcntl.flock(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except:
+ f.close()
+ raise
+ except OSError:
display += 1
continue
return display, f
|