Threading for webbrowser on Win32 (partially fixes #142 for good). (#145)

Tested on Vivaldi (Chrome-based), qutebrowser (PyWebKit-based), Pale Moon (Firefox fork) and Firefox Developer Edition. It works as intended *if* the current default browser (or whatever Buku thinks the default browser is) is actively running. Depending on the browser, it still only opens everything in one tab if it is *not* running yet. But who closes his browser anyway? :-)
This commit is contained in:
Cthulhux 2017-04-03 21:44:02 +02:00 committed by Arun Prakash Jana
parent a576e54bed
commit 0923fa0d7f

View File

@ -2245,7 +2245,14 @@ def browse(url):
os.dup2(fd, 2)
os.dup2(fd, 1)
try:
webbrowser.open(url, new=2)
if sys.platform != 'win32':
webbrowser.open(url, new=2)
else:
# On Windows, the webbrowser module does not fork.
# Use threads instead.
browserthread = lambda: webbrowser.open(url, new=2)
t = threading.Thread(target=browserthread)
t.start()
except Exception as e:
logerr('browse(): %s', e)
finally: