ComfyUI/comfy/entrypoints/worker.py
doctorpangloss 98ae55b059 Improvements to compatibility with custom nodes, distributed
backends and other changes

 - remove uv.lock since it will not be used in most cases for installation
 - add cli args to prevent some custom nodes from installing packages at runtime
 - temp directories can now be shared between workers without being deleted
 - propcache yanked is now in the dependencies
 - fix configuration arguments loading in some tests
2025-11-04 17:40:19 -08:00

43 lines
1.3 KiB
Python

import asyncio
from ..cmd.main_pre import args
from ..component_model.file_counter import cleanup_temp
from ..component_model.entrypoints_common import configure_application_paths, executor_from_args
async def main():
# assume we are a worker
from ..distributed.distributed_prompt_worker import DistributedPromptWorker
args.distributed_queue_worker = True
args.distributed_queue_frontend = False
# in workers, there is a different default
if args.block_runtime_package_installation is None:
args.block_runtime_package_installation = True
assert args.distributed_queue_connection_uri is not None, "Set the --distributed-queue-connection-uri argument to your RabbitMQ server"
configure_application_paths(args)
executor = await executor_from_args(args)
async with (
DistributedPromptWorker(connection_uri=args.distributed_queue_connection_uri,
queue_name=args.distributed_queue_name,
executor=executor),
):
with cleanup_temp():
stop = asyncio.Event()
try:
await stop.wait()
except (asyncio.CancelledError, InterruptedError, KeyboardInterrupt):
pass
def entrypoint():
asyncio.run(main())
if __name__ == "__main__":
entrypoint()