webpack: Close potential race condition leaking webpack-dev-server process.

This exchanges a race condition where webpack-dev-server might not be
stopped on a poorly timed KeyboardInterrupt for a less bad race
condition where we might get an UnboundLocalError.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-05-31 17:05:56 -07:00
parent cf921d5981
commit faa4cf629a
1 changed files with 11 additions and 11 deletions

View File

@ -58,6 +58,7 @@ def build_for_dev_server(host, port, minify, disable_host_check):
if disable_host_check: if disable_host_check:
webpack_args.append('--disable-host-check') webpack_args.append('--disable-host-check')
try:
webpack_process = subprocess.Popen(webpack_args) webpack_process = subprocess.Popen(webpack_args)
class WebpackConfigFileChangeHandler(pyinotify.ProcessEvent): class WebpackConfigFileChangeHandler(pyinotify.ProcessEvent):
@ -69,7 +70,6 @@ def build_for_dev_server(host, port, minify, disable_host_check):
webpack_process.wait() webpack_process.wait()
webpack_process = subprocess.Popen(webpack_args) webpack_process = subprocess.Popen(webpack_args)
try:
watch_manager = pyinotify.WatchManager() watch_manager = pyinotify.WatchManager()
event_notifier = pyinotify.Notifier(watch_manager, WebpackConfigFileChangeHandler()) event_notifier = pyinotify.Notifier(watch_manager, WebpackConfigFileChangeHandler())
for file in ['webpack.config.ts', 'webpack-helpers.ts', 'webpack.assets.json']: for file in ['webpack.config.ts', 'webpack-helpers.ts', 'webpack.assets.json']: