This commit is contained in:
retoor 2025-04-08 10:42:07 +02:00
parent 22d646e8ae
commit 91d22f25fe
2 changed files with 4 additions and 5 deletions

View File

@ -51,11 +51,10 @@ async def websocket_client(url: str, ollama_url: str) -> None:
async def main(concurrency: int, ollama_url: str) -> None: async def main(concurrency: int, ollama_url: str) -> None:
url = 'https://ollama.molodetz.nl' url = 'https://ollama.molodetz.nl'
tasks = []
for _ in range(concurrency):
tasks.append(websocket_client(url, ollama_url))
while True: while True:
tasks = []
for _ in range(concurrency):
tasks.append(websocket_client(url, ollama_url))
try: try:
await asyncio.gather(*tasks) await asyncio.gather(*tasks)
except Exception as e: except Exception as e:

View File

@ -113,7 +113,7 @@ async def http_handler(request):
import json import json
try: try:
async for result in server_manager.forward_to_websocket(request_id, data, path=request.path): async for result in server_manager.forward_to_websocket(request_id, data, path=request.path):
await resp.write(json.dumps(result).encode() + b'\n') await resp.write(json.dumps(result).encode())
except NoServerFoundException: except NoServerFoundException:
await resp.write(json.dumps(dict(error="No server with that model found.",available=server_manager.get_models())).encode() + b'\n') await resp.write(json.dumps(dict(error="No server with that model found.",available=server_manager.get_models())).encode() + b'\n')
await resp.write_eof() await resp.write_eof()