MCPcopy Index your code
hub / github.com/alievk/avatarify-python / check_connection

Function check_connection

afy/networking.py:10–26  ·  view source on GitHub ↗
(socket, timeout=1000)

Source from the content-addressed store, hash-verified

8
9
10def check_connection(socket, timeout=1000):
11 old_rcvtimeo = socket.RCVTIMEO
12 socket.RCVTIMEO = timeout
13
14 try:
15 data = msgpack.packb(([], {}))
16 socket.send_data('hello', data)
17 attr_recv, data_recv = socket.recv_data()
18 response = msgpack.unpackb(data_recv)
19 except zmq.error.Again:
20 return False
21 finally:
22 socket.RCVTIMEO = old_rcvtimeo
23
24 log(f"Response to hello is {response}")
25
26 return response == 'OK'
27
28
29class SerializingSocket(zmq.Socket):

Callers

nothing calls this directly

Calls 3

logFunction · 0.90
send_dataMethod · 0.80
recv_dataMethod · 0.80

Tested by

no test coverage detected