This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add timeout for web_channel in trial_runner #2710
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
dcd2ffd
Merge pull request #251 from microsoft/master
SparkSnail 3b8b6fb
Merge pull request #252 from microsoft/master
SparkSnail 916e444
Merge pull request #253 from microsoft/master
SparkSnail caeffb8
Merge pull request #254 from microsoft/master
SparkSnail 57c300e
Merge pull request #255 from microsoft/master
SparkSnail 65660e6
Merge pull request #257 from microsoft/master
SparkSnail 9376d6a
Merge pull request #258 from microsoft/master
SparkSnail 5fef3cf
Merge pull request #259 from microsoft/master
SparkSnail 5544ae8
Merge pull request #261 from microsoft/master
SparkSnail c5e26ef
add trial job detail link
SparkSnail 785a324
Revert "add trial job detail link"
SparkSnail 0f0567c
fix webchannel connection
SparkSnail bcab8a9
refactor logic
SparkSnail 15ea95a
add timeout
SparkSnail a3b9d39
format
SparkSnail 4a8dbcb
reset timeout value
SparkSnail 6b9dd71
fix comments
SparkSnail ab8e130
unify code to use os._exit(1)
SparkSnail b8fbc9d
fix typo
SparkSnail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# Licensed under the MIT license. | ||
|
||
import asyncio | ||
|
||
import os | ||
import websockets | ||
|
||
from .base_channel import BaseChannel | ||
|
@@ -16,19 +16,23 @@ def __init__(self, args): | |
self.args = args | ||
self.client = None | ||
self.in_cache = b"" | ||
self.timeout = 10 | ||
|
||
super(WebChannel, self).__init__(args) | ||
|
||
self._event_loop = None | ||
|
||
def _inner_open(self): | ||
url = "ws://{}:{}".format(self.args.nnimanager_ip, self.args.nnimanager_port) | ||
nni_log(LogType.Info, 'WebChannel: connected with info %s' % url) | ||
|
||
connect = websockets.connect(url) | ||
self._event_loop = asyncio.get_event_loop() | ||
client = self._event_loop.run_until_complete(connect) | ||
self.client = client | ||
try: | ||
connect = asyncio.wait_for(websockets.connect(url), self.timeout) | ||
self._event_loop = asyncio.get_event_loop() | ||
client = self._event_loop.run_until_complete(connect) | ||
self.client = client | ||
nni_log(LogType.Info, 'WebChannel: connected with info %s' % url) | ||
except asyncio.TimeoutError: | ||
nni_log(LogType.Error, 'connect to %s timeout! Please make sure NNIManagerIP configured correclty, and accessable.' % url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
os._exit(1) | ||
|
||
def _inner_close(self): | ||
if self.client is not None: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to hang at this line in some cases? Is a timeout needed for event loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This self._event_loop.run_until_complete(connect) is for connect method, and connect has already handled timeout.