34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
+
|
sock.connect(monitor_path)
except IOError as ex:
if ex.errno == errno.ECONNREFUSED:
# virtal machine is not running
return None
else:
raise ex
readfd, dummy_w, dummy_x = select.select([sock], [], [], 0.001)
readfd, dummy_w, dummy_x = select.select([sock], [], [], 0.1)
if sock in readfd:
dummy_greeting = sock.recv(1024)
return sock
def send_command(sock, command):
""" Sends monitor command to given socket and returns answer """
fcntl.flock(sock, fcntl.LOCK_EX)
|