MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / check_server_running

Function check_server_running

camel/utils/commons.py:158–177  ·  view source on GitHub ↗

r"""Check whether the port refered by the URL to the server is open. Args: server_url (str): The URL to the server running LLM inference service. Returns: bool: Whether the port is open for packets (server is running).

(server_url: str)

Source from the content-addressed store, hash-verified

156
157
158def check_server_running(server_url: str) -> bool:
159 r"""Check whether the port refered by the URL to the server
160 is open.
161
162 Args:
163 server_url (str): The URL to the server running LLM inference
164 service.
165
166 Returns:
167 bool: Whether the port is open for packets (server is running).
168 """
169 parsed_url = urlparse(server_url)
170 url_tuple = (parsed_url.hostname, parsed_url.port)
171
172 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
173 result = sock.connect_ex(url_tuple)
174 sock.close()
175
176 # if the port is open, the result should be 0.
177 return result == 0
178
179
180def dependencies_required(*required_modules: str) -> Callable[[F], F]:

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected