MCPcopy Create free account
hub / github.com/apache/tvm / _connect

Function _connect

python/tvm/rpc/proxy.py:689–724  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

687
688 @gen.coroutine
689 def _connect(key):
690 conn = yield websocket.websocket_connect(url)
691 on_message = create_on_message(conn)
692 temp = _server_env(None)
693 # Start connecton
694 conn.write_message(struct.pack("<i", base.RPC_MAGIC), binary=True)
695 key = "server:" + key
696 conn.write_message(struct.pack("<i", len(key)), binary=True)
697 conn.write_message(key.encode("utf-8"), binary=True)
698 msg = yield conn.read_message()
699 assert len(msg) >= 4
700 magic = struct.unpack("<i", msg[:4])[0]
701 if magic == base.RPC_CODE_DUPLICATE:
702 raise RuntimeError(f"key: {key} has already been used in proxy")
703 if magic == base.RPC_CODE_MISMATCH:
704 logging.info("RPCProxy do not have matching client key %s", key)
705 elif magic != base.RPC_CODE_SUCCESS:
706 raise RuntimeError(f"{url} is not RPC Proxy")
707 msg = msg[4:]
708
709 logging.info("Connection established with remote")
710
711 if msg:
712 on_message(bytearray(msg), 3)
713
714 while True:
715 try:
716 msg = yield conn.read_message()
717 if msg is None:
718 break
719 on_message(bytearray(msg), 3)
720 except websocket.WebSocketClosedError as err:
721 break
722 logging.info("WebSocketProxyServer closed...")
723 temp.remove()
724 ioloop.IOLoop.current().stop()
725
726 ioloop.IOLoop.current().spawn_callback(_connect, key)
727 ioloop.IOLoop.current().start()

Callers

nothing calls this directly

Calls 10

create_on_messageFunction · 0.85
_server_envFunction · 0.85
write_messageMethod · 0.80
packMethod · 0.80
encodeMethod · 0.80
unpackMethod · 0.80
infoMethod · 0.80
stopMethod · 0.80
removeMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…