From 509da7f73ef94dfedbca856799d32ac9338bf2e3 Mon Sep 17 00:00:00 2001 From: tazlin Date: Wed, 2 Oct 2024 13:43:52 -0400 Subject: [PATCH] fix: use a `certifi` ssl context for r2 uploads This is tied to a bug of unclear root-cause but whose practical effect is that the root signing certificate was not being found on a relatively fresh windows 10 pro machine. `certifi` should already be being pulled in, but I've marked it as an explicit requirement and I anticipate that there should not be side effects on machines which were previously running fine. --- horde_worker_regen/process_management/process_manager.py | 5 +++++ requirements.txt | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/horde_worker_regen/process_management/process_manager.py b/horde_worker_regen/process_management/process_manager.py index 63022950..a14629f1 100644 --- a/horde_worker_regen/process_management/process_manager.py +++ b/horde_worker_regen/process_management/process_manager.py @@ -8,6 +8,7 @@ import os import queue import random +import ssl import sys import time from asyncio import CancelledError, Task @@ -22,6 +23,7 @@ import aiohttp import aiohttp.client_exceptions +import certifi import PIL import PIL.Image import psutil @@ -89,6 +91,8 @@ ) from horde_worker_regen.process_management.worker_entry_points import start_inference_process, start_safety_process +sslcontext = ssl.create_default_context(cafile=certifi.where()) + # This is due to Linux/Windows differences in the multiprocessing module try: from multiprocessing.connection import PipeConnection as Connection # type: ignore @@ -2469,6 +2473,7 @@ async def _do_upload(new_submit: PendingSubmitJob, image_in_buffer_bytes: bytes) data=image_in_buffer_bytes, skip_auto_headers=["content-type"], timeout=aiohttp.ClientTimeout(total=10), + ssl=sslcontext, ) as response: if response.status != 200: logger.error(f"Failed to upload image to R2: {response}") diff --git a/requirements.txt b/requirements.txt index c039b1fe..d9d265a5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ numpy==1.26.4 torch==2.3.1 -qrcode==7.4.2 +qrcode==7.4.2 # >8 breaks horde-engine 2.15.3 via the qr code generation nodes + +certifi # Required for SSL cert resolution horde_sdk~=0.14.11 horde_safety~=0.2.3