]> granicus.if.org Git - python/commitdiff
Closes #15499: Sleep is hardcoded in webbrowser.UnixBrowser
authorJesus Cea <jcea@jcea.es>
Wed, 1 Aug 2012 01:57:52 +0000 (03:57 +0200)
committerJesus Cea <jcea@jcea.es>
Wed, 1 Aug 2012 01:57:52 +0000 (03:57 +0200)
Lib/webbrowser.py
Misc/NEWS

index 5b441e6ecc067178478c121cf45952f5ed6a2078..ce5b48e00dbfa141cfad09d557e816f1a835e04a 100644 (file)
@@ -232,17 +232,14 @@ class UnixBrowser(BaseBrowser):
                              stdout=(self.redirect_stdout and inout or None),
                              stderr=inout, start_new_session=True)
         if remote:
-            # wait five seconds. If the subprocess is not finished, the
+            # wait at most five seconds. If the subprocess is not finished, the
             # remote invocation has (hopefully) started a new instance.
-            time.sleep(1)
-            rc = p.poll()
-            if rc is None:
-                time.sleep(4)
-                rc = p.poll()
-                if rc is None:
-                    return True
-            # if remote call failed, open() will try direct invocation
-            return not rc
+            try:
+                rc = p.wait(5)
+                # if remote call failed, open() will try direct invocation
+                return not rc
+            except subprocess.TimeoutExpired:
+                return True
         elif self.background:
             if p.poll() is None:
                 return True
index 0d21d64edd9e7e0d972d529ecab11dcc8fc59057..b1df727fa49a140b6942805c9296917b13334544 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -72,6 +72,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #15499: Launching a webbrowser in Unix used to sleep for a few
+  seconds.  Original patch by Anton Barkovsky.
+  
 - Issue #15463: the faulthandler module truncates strings to 500 characters,
   instead of 100, to be able to display long file paths