Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9aa321

Browse files
committed
Closes #15499: Sleep is hardcoded in webbrowser.UnixBrowser
1 parent 0efcf99 commit c9aa321

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Lib/webbrowser.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,14 @@ def _invoke(self, args, remote, autoraise):
232232
stdout=(self.redirect_stdout and inout or None),
233233
stderr=inout, start_new_session=True)
234234
if remote:
235-
# wait five seconds. If the subprocess is not finished, the
235+
# wait at most five seconds. If the subprocess is not finished, the
236236
# remote invocation has (hopefully) started a new instance.
237-
time.sleep(1)
238-
rc = p.poll()
239-
if rc is None:
240-
time.sleep(4)
241-
rc = p.poll()
242-
if rc is None:
243-
return True
244-
# if remote call failed, open() will try direct invocation
245-
return not rc
237+
try:
238+
rc = p.wait(5)
239+
# if remote call failed, open() will try direct invocation
240+
return not rc
241+
except subprocess.TimeoutExpired:
242+
return True
246243
elif self.background:
247244
if p.poll() is None:
248245
return True

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Core and Builtins
7272
Library
7373
-------
7474

75+
- Issue #15499: Launching a webbrowser in Unix used to sleep for a few
76+
seconds. Original patch by Anton Barkovsky.
77+
7578
- Issue #15463: the faulthandler module truncates strings to 500 characters,
7679
instead of 100, to be able to display long file paths
7780

0 commit comments

Comments
 (0)