Comment 26 for bug 315996

Revision history for this message
Lawrence (annon0m0s) wrote :

This might help some to figuring out the cause of the problem. I made a copy of launch_webbrowser.py in another directory and made a few changes (1) change the url to a constant. (2) added another call to webbrowser to see if things are working (3) added print statements to say "got here". The quirky thing about this is that it works. The last line, webbrowser.open, seems to allow both pages to be shown. If the last line is commented out then both pages are not shown. So there seems to be something weird about running webbrowser from within a thread. I changed the threaded webbrowser call back to using the default and again it works only when the call to at the end to webbrowser is not commented out.
#!/usr/bin/env python
import webbrowser, threading
from optparse import OptionParser
print 'starting'
class VisitWebSiteWithoutLockingInkscape(threading.Thread):
    def __init__(self):
        threading.Thread.__init__ (self)
        print 'inside init'
        parser = OptionParser()
        parser.add_option("-u", "--url", action="store", type="string",
                          default="http://www.inkscape.org/",
                          dest="url", help="The URL to open in web browser")
        (self.options, args) = parser.parse_args()
        print 'end of init'

    def run(self):
        print 'start of run url=' + str(self.options.url)
        webbrowser.open(self.options.url)
        #webbrowser.open("http://inkscape.org/doc/keys046.html")
        print 'end of run'

print 'after class def'
vwswli = VisitWebSiteWithoutLockingInkscape()
vwswli.start()
print 'after thread started'
webbrowser.open("http://inkscape.org/doc/keys046.html")