Skip to content

Commit 842f9c4

Browse files
committed
fix: prevent zombie process when canceling on web
1 parent 0a3332d commit 842f9c4

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ output/
3232
dev_output/
3333

3434
.env
35-
.DS_Store
35+
docker-compose.yml
3636

37+
.DS_Store

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copy this file to .env and fill your real keys
22

3-
AZURE_TTS_KEY=YOUR_AZURE_SPEECH_KEY
3+
AZURE_TTS_KEY=your_azure_speech_key
44

5-
AZURE_TTS_REGION=YOUR_REGION
5+
AZURE_TTS_REGION=your_speech_region
66

77
AUDIBLE_EPUB3_MAKER_ENV=production

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ logs/*
1313
!logs/.gitkeep
1414

1515
.env
16+
docker-compose.yml
17+
1618
.DS_Store
1719
report.html
1820
manual_test.py

audible_epub3_maker/utils/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Internal configuration (not intended for user modification) ##
33

44
APP_NAME = "Audible EPUB3 Maker"
5-
APP_VERSION = "0.3.0"
5+
APP_VERSION = "0.3.1"
66
APP_FULLNAME = APP_NAME + " v" + APP_VERSION
77
APP_IN_DEV = True
88

docker-compose.example.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
version: '3.8'
2-
31
services:
4-
aem:
5-
image: ghcr.io/funway/audible-epub3-maker # or funway/audible-epub3-maker
2+
aem-web:
3+
image: funway/audible-epub3-maker # or ghcr.io/funway/audible-epub3-maker
64
ports:
75
- "7860:7860"
86
volumes:

web_gui.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,17 @@ def on_cancel_click():
191191
global aem_process
192192

193193
if aem_process and aem_process.poll() is None:
194-
aem_process.terminate()
195-
aem_process = None
196-
gr.Info(f"AEM process terminated")
194+
try:
195+
aem_process.terminate()
196+
aem_process.wait(0.5)
197+
gr.Info(f"AEM process terminated")
198+
except subprocess.TimeoutExpired:
199+
aem_process.kill()
200+
gr.Warning(f"Force kill AEM process [{aem_process.pid}]")
201+
except Exception as e:
202+
raise gr.Error(f"Error terminating AEM process [{aem_process.pid}]")
197203
else:
198-
gr.Warning(f"No AEM process running")
204+
gr.Info(f"No AEM process running")
199205

200206

201207
def on_engine_change(tts_engine):
@@ -355,11 +361,12 @@ def launch_gui(host: str = "127.0.0.1", port: int = 7860):
355361
inputs=None,
356362
outputs=None
357363
)
364+
# gr.Timer is triggered from the frontend browser
358365
gr.Timer(0.5).tick(
359366
fn=check_process,
360367
inputs=None,
361368
outputs=[run_btn]
362-
)
369+
)
363370
gr.Timer(0.5).tick(
364371
fn=tail_log_file,
365372
inputs=None,

0 commit comments

Comments
 (0)