Skip to content

Commit 20e2db8

Browse files
committed
Handle stout and stderr reader thread gradeful termination
1 parent b443a03 commit 20e2db8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

frontend/server/src/main/java/org/pytorch/serve/wlm/WorkerLifeCycle.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,15 @@ public void terminate() {
380380
@Override
381381
public void run() {
382382
try (Scanner scanner = new Scanner(is, StandardCharsets.UTF_8.name())) {
383-
while (scanner.hasNext()) {
383+
while (scanner.hasNextLine()) {
384384
String result = scanner.nextLine();
385-
if (result == null && !isRunning.get()) {
386-
break;
385+
if (result == null) {
386+
if (isRunning.get()) {
387+
continue;
388+
}
389+
else {
390+
break;
391+
}
387392
}
388393

389394
Matcher matcher = METRIC_PATTERN.matcher(result);

0 commit comments

Comments
 (0)