Skip to content
Snippets Groups Projects
Commit 938e7e04 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Avoid concurrent access to the datorhandbok server.

parent c95bb6c4
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import re import re
import urllib2 import urllib2
import fcntl
import BeautifulSoup import BeautifulSoup
...@@ -58,7 +59,16 @@ def check_host(hostname): ...@@ -58,7 +59,16 @@ def check_host(hostname):
ok(hostname, "all ok") ok(hostname, "all ok")
def check_host_locked(hostname):
f = open("/tmp/datorhandok.lck", "a")
try:
fcntl.flock(f, fcntl.LOCK_EX)
check_host(hostname)
finally:
fcntl.flock(f, fcntl.LOCK_UN)
f.close()
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
check_host(sys.argv[1]) check_host_locked(sys.argv[1])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment