Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Python comms to hold onto server endpoints #241

Merged
merged 1 commit into from
May 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion python/raft/dask/common/ucx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


async def _connection_func(ep):
return 0
UCX.get().add_server_endpoint(ep)


class UCX:
Expand All @@ -35,6 +35,7 @@ def __init__(self, listener_callback):

self._create_listener()
self._endpoints = {}
self._server_endpoints = []

assert UCX.__instance is None

Expand All @@ -60,6 +61,9 @@ async def _create_endpoint(self, ip, port):
self._endpoints[(ip, port)] = ep
return ep

def add_server_endpoint(self, ep):
self._server_endpoints.append(ep)

async def get_endpoint(self, ip, port):
if (ip, port) not in self._endpoints:
ep = await self._create_endpoint(ip, port)
Expand All @@ -72,10 +76,18 @@ async def close_endpoints(self):
for k, ep in self._endpoints.items():
await ep.close()

for ep in self._server_endpoints:
ep.close()

def __del__(self):
for ip_port, ep in self._endpoints.items():
if not ep.closed():
ep.abort()
del ep

for ep in self._server_endpoints:
if not ep.closed():
ep.abort()
del ep

self._listener.close()