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

Commit

Permalink
fix multi-thread issue (#3899)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanluZhang authored Jul 30, 2021
1 parent 703f6de commit 6645bd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions nni/retiarii/experiment/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,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 @@ -326,9 +331,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 @@ -639,8 +639,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 @@ -665,6 +663,8 @@ class NNIManager implements Manager {
}
}
} else {
this.requestTrialJobs(requestTrialNum);

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

0 comments on commit 6645bd3

Please sign in to comment.