code of webbrowser.py

Michel Van den Bergh vdbergh at luc.ac.be
Sat May 15 08:59:45 EDT 2004


Hello,

I was looking at the code of webbrowser.py included in python 2.3.3. I 
think there are some
obvious problems with it (tested with mozilla on Linux).

(*) If you open an url (with the option "new window") and the browser is 
not already running
then it opens *two* windows: the home page and your url. This is 
different for example
from the default behaviour on Windows.

(**) There is another related problem: if you open an url
and the browser is not already running then the code starts a new 
browser, does a timed sleep
and then issues a "-remote" command.

Using a timed sleep is *very fragile*, and indeed I had failures because 
the delay
(PROCESS_CREATION_DELAY) was not long enough. At the very least the -remote
command should be tried a couple of times.

BUT: there is no reason *at all* to issue a -remote command in this 
case. All browsers I know
accept an url as argument. So one can just start a new browser with the 
url as argument.

(***) Mozilla type browsers now have a -remote "ping()" command. This is 
perhaps a
cleaner way to detect a running browser.

Any comments?

Best regards,
Michel






More information about the Python-list mailing list