Rewrite runpod_handler.py with clean formatting - no whitespace issues

This commit is contained in:
Bahadir Ciloglu 2025-11-01 16:02:20 +03:00
parent dc5a696d3b
commit 236a174b18

View File

@ -22,6 +22,7 @@ logging.basicConfig(
) )
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class ComfyUIServerlessHandler: class ComfyUIServerlessHandler:
def __init__(self): def __init__(self):
self.comfyui_url = "http://127.0.0.1:8000" self.comfyui_url = "http://127.0.0.1:8000"
@ -202,6 +203,7 @@ class ComfyUIServerlessHandler:
except Exception as e: except Exception as e:
logger.error(f"Cleanup failed: {str(e)}") logger.error(f"Cleanup failed: {str(e)}")
def handler(job: Dict[str, Any]) -> Dict[str, Any]: def handler(job: Dict[str, Any]) -> Dict[str, Any]:
"""Main serverless handler function""" """Main serverless handler function"""
handler_instance = ComfyUIServerlessHandler() handler_instance = ComfyUIServerlessHandler()
@ -260,6 +262,7 @@ def handler(job: Dict[str, Any]) -> Dict[str, Any]:
# Always cleanup # Always cleanup
handler_instance.cleanup() handler_instance.cleanup()
if __name__ == "__main__": if __name__ == "__main__":
# Start the serverless worker # Start the serverless worker
runpod.serverless.start({"handler": handler}) runpod.serverless.start({"handler": handler})