From b915d741275c9e2573b5cc88ff76fe5ce0d59833 Mon Sep 17 00:00:00 2001 From: Brandon <58442074+brandonrising@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:30:01 -0400 Subject: [PATCH] =?UTF-8?q?Remove=20fastapi-socketio=20dependency,=20doesn?= =?UTF-8?q?'t=20really=20do=20much=20for=20us=20and=E2=80=A6=20(#4552)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove fastapi-socketio dependency, doesn't really do much for us and isn't well maintained * Run python black * Remove fastapi_socketio import * Add __app as class variable in case we ever need it later * Run isort --------- Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com> --- invokeai/app/api/sockets.py | 9 ++++++--- pyproject.toml | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/invokeai/app/api/sockets.py b/invokeai/app/api/sockets.py index 20fa6606bd..ae699f35ef 100644 --- a/invokeai/app/api/sockets.py +++ b/invokeai/app/api/sockets.py @@ -3,16 +3,19 @@ from fastapi import FastAPI from fastapi_events.handlers.local import local_handler from fastapi_events.typing import Event -from fastapi_socketio import SocketManager +from socketio import ASGIApp, AsyncServer from ..services.events import EventServiceBase class SocketIO: - __sio: SocketManager + __sio: AsyncServer + __app: ASGIApp def __init__(self, app: FastAPI): - self.__sio = SocketManager(app=app) + self.__sio = AsyncServer(async_mode="asgi", cors_allowed_origins="*") + self.__app = ASGIApp(socketio_server=self.__sio, socketio_path="socket.io") + app.mount("/ws", self.__app) self.__sio.on("subscribe_queue", handler=self._handle_sub_queue) self.__sio.on("unsubscribe_queue", handler=self._handle_unsub_queue) diff --git a/pyproject.toml b/pyproject.toml index 60041aa836..b9410999ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,6 @@ dependencies = [ "facexlib", "fastapi==0.88.0", "fastapi-events==0.8.0", - "fastapi-socketio==0.0.10", "huggingface-hub~=0.16.4", "invisible-watermark~=0.2.0", # needed to install SDXL base and refiner using their repo_ids "matplotlib", # needed for plotting of Penner easing functions