Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upadd traitlet to ServePostProcessor that configures the browser used #618
Conversation
mpacer
added some commits
Jun 29, 2017
This comment has been minimized.
This comment has been minimized.
I think that wrapping it in a thread is needed in some situations, because |
This comment has been minimized.
This comment has been minimized.
I believe it's only on Linux where |
This comment has been minimized.
This comment has been minimized.
I think it can happen on any system if you have the BROWSER environment variable set; that's registered as a |
takluyver
reviewed
Jul 20, 2017
webbrowser.open(url, new=2) | ||
try: | ||
browser = webbrowser.get(self.browser or None) | ||
threading.Thread(target=(browser.open(url, new=2))).start() |
This comment has been minimized.
This comment has been minimized.
takluyver
Jul 20, 2017
Member
This won't actually do it in a thread - you're calling browser.open()
in the main thread, and passing its return value as the target=
parameter.
You can either use a lambda, like we do in notebook, or pass args and kwargs separately, like this:
Thread(target=browser.open, args=(url,), kwargs={'new': 2})
Both ways are a bit ugly, unfortunately.
mpacer commentedJun 29, 2017
This closes #614.
I took some of the design of how the notebook implemented this and tried to abstract away only those parts that we needed.
In particular, I didn't run the
browser.open
command usingthreading.thread
, since multi-threading didn't seem necessary, but that might be wrong. Could use others' insights.