Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
77 lines
1.7 KiB
Python
77 lines
1.7 KiB
Python
import time
|
|
|
|
from threading import Thread, Lock
|
|
|
|
|
|
class Listener:
|
|
task_queue = []
|
|
lock = Lock()
|
|
thread = None
|
|
|
|
@classmethod
|
|
def _process_tasks(cls):
|
|
while True:
|
|
task = None
|
|
with cls.lock:
|
|
if cls.task_queue:
|
|
task = cls.task_queue.pop(0)
|
|
|
|
if task is None:
|
|
time.sleep(0.001)
|
|
continue
|
|
|
|
func, args, kwargs = task
|
|
try:
|
|
func(*args, **kwargs)
|
|
except Exception as e:
|
|
print(f"Error in listener thread: {e}")
|
|
|
|
@classmethod
|
|
def add_task(cls, func, *args, **kwargs):
|
|
with cls.lock:
|
|
cls.task_queue.append((func, args, kwargs))
|
|
|
|
if cls.thread is None:
|
|
cls.thread = Thread(target=cls._process_tasks, daemon=True)
|
|
cls.thread.start()
|
|
|
|
|
|
def async_run(func, *args, **kwargs):
|
|
Listener.add_task(func, *args, **kwargs)
|
|
|
|
|
|
class FIFOQueue:
|
|
def __init__(self):
|
|
self.queue = []
|
|
self.lock = Lock()
|
|
|
|
def push(self, item):
|
|
with self.lock:
|
|
self.queue.append(item)
|
|
|
|
def pop(self):
|
|
with self.lock:
|
|
if self.queue:
|
|
return self.queue.pop(0)
|
|
return None
|
|
|
|
def top(self):
|
|
with self.lock:
|
|
if self.queue:
|
|
return self.queue[0]
|
|
return None
|
|
|
|
def next(self):
|
|
while True:
|
|
with self.lock:
|
|
if self.queue:
|
|
return self.queue.pop(0)
|
|
|
|
time.sleep(0.001)
|
|
|
|
|
|
class AsyncStream:
|
|
def __init__(self):
|
|
self.input_queue = FIFOQueue()
|
|
self.output_queue = FIFOQueue()
|