Skip to content

Commit

Permalink
Import aiohttp for ws_client_loop; report exceptions in client loop m…
Browse files Browse the repository at this point in the history
…ore comprehensively
  • Loading branch information
charles-dyfis-net committed Aug 18, 2023
1 parent 421a709 commit fceda86
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lmql/models/lmtp/lmtp_dcmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any, List, Union
import random
import sys
import traceback

class LMTPDcModel(DcModel):
def __init__(self, model, tokenizer, endpoint, inprocess=False, truncation_threshold=-3e+38, init_workers=True, lmtp_server_kwargs=None, inprocess_client_constructor=None, **kwargs):
Expand Down Expand Up @@ -81,6 +82,7 @@ async def replicate_client_loop(self):
self.connected_signal.set()

async def ws_client_loop(self):
import aiohttp
from .lmtp_client import LMTPWebSocketClient

try:
Expand All @@ -93,8 +95,9 @@ async def ws_client_loop(self):
await self.close_signal.wait()
except Exception as e:
self.error_signal.set()
self.error = "Failed to communicate with lmtp endpoint: {}. Please check that the endpoint is correct and the server is running.".format(self.endpoint)
self.error = f"Exception {e!s} attempting to communicate with lmtp endpoint: {self.endpoint!s}. Please check that the endpoint is correct and the server is running."
self.connected_signal.set()
traceback.print_tb(e.__traceback__)

def make_cache_entry(self, s, payload, sampling_mode):
scores = {}
Expand Down

0 comments on commit fceda86

Please sign in to comment.