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

fix force kill for elastic #34488

Merged
merged 2 commits into from
Jul 30, 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
11 changes: 9 additions & 2 deletions python/paddle/distributed/fleet/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def __init__(self, args):
self.stopped = False

self.sigint = 0
self.need_sync = False

if not server or ':' not in server or not name or not np:
logger.info(
Expand Down Expand Up @@ -177,6 +178,7 @@ def host_call_back(event):
logger.info('register host again {}'.format(self.host))

self.etcd.put(self.host_path, six.b(self.host))
self.need_sync = True

host_watch = self.etcd.add_watch_callback(self.host_path,
host_call_back)
Expand Down Expand Up @@ -254,6 +256,7 @@ def _completed(self):
return int(self.etcd.get(self.prefix)[0]) == 1

def _match(self):

self.hosts = [
six.ensure_str(i[0]) for i in self.etcd.get_prefix(self.node_prefix)
]
Expand Down Expand Up @@ -307,7 +310,8 @@ def wait(self):
self.hosts))

idx += 1
time.sleep(3)
time.sleep(2)

return

def run(self, launcher):
Expand All @@ -319,6 +323,9 @@ def run(self, launcher):

def watch(self):

if self.need_sync:
self.need_sync = False

while not self.stopped:
ret = self.launcher.watch()

Expand All @@ -334,7 +341,7 @@ def watch(self):
else:
return ElasticStatus.ERROR

if not self._completed() and not self._match():
if not self._completed() and (not self._match() or self.need_sync):
self.launcher.stop()
return ElasticStatus.HOLD

Expand Down