-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlock.py
54 lines (46 loc) · 928 Bytes
/
lock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
serverLock = ""
#
# Acquire the lock and store the ip of the lock holder in the global variable
#
def acquire(ip):
global serverLock
serverLock = ip
#
# Check if the lock is currently locked
#
def locked():
global serverLock
if serverLock == "":
return False
else:
return True
#
# Check if the lock is currently unlocked
#
def unlocked():
global serverLock
if serverLock == "":
return True
else:
return False
#
# Release the lock and make the server available again
#
def release():
global serverLock
serverLock = ""
#
# Check if the ip is the current lock holder
#
def check_lock(ip):
global serverLock
if ip == serverLock:
return True
else:
return False
#
# Return the IP of the current lock holder
#
def return_lock():
global serverLock
return serverLock