Skip to content
Open
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
10 changes: 8 additions & 2 deletions gateway_provisioners/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def launch_kernel(self, cmd: list[str], **kwargs: Any) -> KernelConnection
"""
self.kernel_log = None
env_dict = kwargs.get("env", {})
self.assigned_host = self._determine_next_host(env_dict)
self.assigned_host = await self.determine_next_host(env_dict)
self.ip = gethostbyname(self.assigned_host) # convert to ip if host is provided
self.assigned_ip = self.ip

Expand Down Expand Up @@ -291,9 +291,15 @@ def _build_startup_command(self, cmd: list[str], **kwargs: Any) -> list[str]:
startup_cmd += f" {arg}"

startup_cmd += f" >> {self.kernel_log} 2>&1 & echo $!" # return the process id

return startup_cmd

async def determine_next_host(self, env_dict: dict) -> str:
"""
This is a placeholder function which can be overridden to implement
custom logic to determine next host.
"""
return self._determine_next_host(env_dict)

def _determine_next_host(self, env_dict: dict) -> str:
"""Simple round-robin index into list of hosts."""
remote_host = env_dict.get("KERNEL_REMOTE_HOST")
Expand Down
Loading