Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from server import PromptServer
|
|
from aiohttp import web
|
|
import time
|
|
import json
|
|
|
|
class MessageCancelled(Exception):
|
|
pass
|
|
|
|
class Message:
|
|
stash = {}
|
|
messages = {}
|
|
cancelled = False
|
|
|
|
@classmethod
|
|
def addMessage(cls, id, message):
|
|
if message == '__cancel__':
|
|
cls.messages = {}
|
|
cls.cancelled = True
|
|
elif message == '__start__':
|
|
cls.messages = {}
|
|
cls.stash = {}
|
|
cls.cancelled = False
|
|
else:
|
|
cls.messages[str(id)] = message
|
|
|
|
@classmethod
|
|
def waitForMessage(cls, id, period=0.1, asList=False):
|
|
sid = str(id)
|
|
while not (sid in cls.messages) and not ("-1" in cls.messages):
|
|
if cls.cancelled:
|
|
cls.cancelled = False
|
|
raise MessageCancelled()
|
|
time.sleep(period)
|
|
if cls.cancelled:
|
|
cls.cancelled = False
|
|
raise MessageCancelled()
|
|
message = cls.messages.pop(str(id), None) or cls.messages.pop("-1")
|
|
try:
|
|
if asList:
|
|
return [str(x.strip()) for x in message.split(",")]
|
|
else:
|
|
try:
|
|
return json.loads(message)
|
|
except ValueError:
|
|
return message
|
|
except ValueError:
|
|
print( f"ERROR IN MESSAGE - failed to parse '${message}' as ${'comma separated list of strings' if asList else 'string'}")
|
|
return [message] if asList else message
|
|
|
|
|
|
@PromptServer.instance.routes.post('/easyuse/message_callback')
|
|
async def message_callback(request):
|
|
post = await request.post()
|
|
Message.addMessage(post.get("id"), post.get("message"))
|
|
return web.json_response({}) |