mirror of
https://github.com/Rudd-O/ansible-qubes.git
synced 2025-03-01 14:22:33 +01:00
bombshell-client gains a lock that prevents it from hanging if two parallel requests happen too fast
This commit is contained in:
parent
8e38ed73bb
commit
eebd457b03
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/python -u
|
||||
|
||||
import cPickle
|
||||
import contextlib
|
||||
import fcntl
|
||||
import os
|
||||
import pipes
|
||||
@ -13,6 +14,18 @@ import sys
|
||||
import threading
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def mutexfile(filepath):
|
||||
oldumask = os.umask(0077)
|
||||
try:
|
||||
f = file(filepath, "a")
|
||||
finally:
|
||||
os.umask(oldumask)
|
||||
fcntl.lockf(f.fileno(), fcntl.LOCK_EX)
|
||||
yield
|
||||
f.close()
|
||||
|
||||
|
||||
debug_lock = threading.Lock()
|
||||
debug_enabled = False
|
||||
class LoggingEmu():
|
||||
@ -250,6 +263,7 @@ def main_master():
|
||||
|
||||
saved_stderr = os.fdopen(os.dup(sys.stderr.fileno()), "a")
|
||||
|
||||
with mutexfile(os.path.expanduser("~/.bombshell-lock")):
|
||||
try:
|
||||
p = subprocess.Popen(
|
||||
["qrexec-client-vm", remote_vm, "qubes.VMShell"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user