Skip to content

Commit

Permalink
fix writeandflush incomplete (#2833)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxning authored Dec 6, 2023
1 parent a1602ba commit f7ae6f8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class WorkerThread implements Runnable {
private WorkerLifeCycle lifeCycle;
private int responseTimeout;
private long recoveryStartTS; // 0: default value. no recovery needed, in healthy mode
private BaseModelRequest req = null;

public WorkerThread(
ConfigManager configManager,
Expand Down Expand Up @@ -182,7 +183,7 @@ public void run() {
Thread thread = Thread.currentThread();
thread.setName(getWorkerName());
currentThread.set(thread);
BaseModelRequest req = null;
req = null;
int status = HttpURLConnection.HTTP_INTERNAL_ERROR;

try {
Expand All @@ -202,12 +203,11 @@ public void run() {
List<CompletableFuture<Void>> futureRequests = new ArrayList<>(repeats);
for (int i = 0; backendChannel.size() > 0 && i < repeats; i++) {
int idx = i;
BaseModelRequest request = req;
futureRequests.add(
CompletableFuture.runAsync(
() -> {
try {
backendChannel.get(idx).writeAndFlush(request).sync();
backendChannel.get(idx).writeAndFlush(req).sync();
} catch (InterruptedException e) {
logger.error("Failed to send request to backend", e);
}
Expand Down

0 comments on commit f7ae6f8

Please sign in to comment.