Skip to content

Commit 7dc554a

Browse files
committed
Quick fix for #416
`webbrowser.open()` doesn't seem to need additional parallelization, but spawn it in a thread just so it can delay to give the web server more time to get ready to serve pages. In any case, not spawning a webserver process fixes the Issue. When `webbrowser.open(url)` has to launch Chrome, Chrome opens the Fireworks `url` in a new window then restores its previous tabs in another window right on top of the Fireworks window, kind of hiding it.
1 parent a2b14e3 commit 7dc554a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ fw_tutorials/firetask/addition_task2.py
5252
fw_tutorials/firetask/words.txt
5353

5454
my_launchpad.yaml
55+
.python-version
56+
FW.json
5557
.DS_Store

fireworks/scripts/lpad_run.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,13 @@ def set_priority(args):
535535
lp.m_logger.info("Finished setting priorities of {} FWs".format(len(fw_ids)))
536536

537537

538+
def _open_webbrowser(url):
539+
"""Open a web browser after a delay to give the web server more startup time."""
540+
import webbrowser
541+
time.sleep(2)
542+
webbrowser.open(url)
543+
544+
538545
def webgui(args):
539546
from fireworks.flask_site.app import app
540547
app.lp = get_lp(args)
@@ -554,14 +561,11 @@ def webgui(args):
554561
app.BASE_Q_WF["state"] = app.BASE_Q["state"]
555562

556563
if not args.server_mode:
557-
from multiprocessing import Process
558-
p1 = Process(
559-
target=app.run,
560-
kwargs={"host": args.host, "port": args.port, "debug": args.debug})
564+
from threading import Thread
565+
url = "http://{}:{}".format(args.host, args.port)
566+
p1 = Thread(target=_open_webbrowser, args=(url,))
561567
p1.start()
562-
import webbrowser
563-
time.sleep(2)
564-
webbrowser.open("http://{}:{}".format(args.host, args.port))
568+
app.run(host=args.host, port=args.port, debug=args.debug)
565569
p1.join()
566570
else:
567571
try:

0 commit comments

Comments
 (0)