Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix multi-thread event handling issue #3899

Merged
merged 1 commit into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions nni/retiarii/experiment/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ def stop(self) -> None:
"""
_logger.info('Stopping experiment, please wait...')
atexit.unregister(self.stop)

# stop strategy first
if self._dispatcher_thread is not None:
self._dispatcher.stopping = True
self._dispatcher_thread.join(timeout=1)

if self.id is not None:
nni.runtime.log.stop_experiment_log(self.id)
Expand All @@ -302,9 +307,6 @@ def stop(self) -> None:

if self._pipe is not None:
self._pipe.close()
if self._dispatcher_thread is not None:
self._dispatcher.stopping = True
self._dispatcher_thread.join(timeout=1)

self.id = None
self.port = None
Expand Down
4 changes: 2 additions & 2 deletions ts/nni_manager/core/nnimanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,6 @@ class NNIManager implements Manager {
this.trialConcurrencyChange = requestTrialNum;
}

this.requestTrialJobs(requestTrialNum);

// check maxtrialnum and maxduration here
// NO_MORE_TRIAL is more like a subset of RUNNING, because during RUNNING tuner
// might tell nnimanager that this is no more trials. In NO_MORE_TRIAL state, the experiment is viewed
Expand All @@ -646,6 +644,8 @@ class NNIManager implements Manager {
}
}
} else {
this.requestTrialJobs(requestTrialNum);

if (this.status.status === 'DONE') {
delete this.experimentProfile.endTime;
await this.storeExperimentProfile();
Expand Down