Introduce retry logic, Install before the imports

This commit is contained in:
henryruhs
2025-07-03 16:16:17 +02:00
parent 5464f4c3de
commit 620910097b
4 changed files with 9 additions and 4 deletions
+2 -1
View File
@@ -1,8 +1,9 @@
from .facefusion_api import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
from .install import install
install()
from .facefusion_api import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
__all__ =\
[
'NODE_CLASS_MAPPINGS',
+4 -1
View File
@@ -9,6 +9,7 @@ from comfy_api.input_impl.video_types import VideoFromComponents
from comfy_api.util import VideoComponents
from comfy_api_nodes.apinode_utils import bytesio_to_image_tensor, tensor_to_bytesio
from httpx import Client as HttpClient, Headers
from httpx_retries import Retry, RetryTransport
from torch import Tensor
from .types import FaceSwapperModel, InputTypes
@@ -69,11 +70,13 @@ class SwapFaceImage:
'face_swapper_model': face_swapper_model,
}
headers = Headers()
retry = Retry(total = 5, backoff_factor = 1)
transport = RetryTransport(retry = retry)
if api_token:
headers['X-Token'] = api_token
with HttpClient(timeout = 10) as http_client:
with HttpClient(transport = transport) as http_client:
response = http_client.post(url, headers = headers, files = files, data = data)
output_buffer = BytesIO(response.content)
+2 -1
View File
@@ -3,4 +3,5 @@ from shutil import which
def install() -> None:
subprocess.run([ which('pip'), 'install', '-r', 'requirements.txt', '-q' ])
subprocess.run([ which('pip'), 'install', 'httpx==0.28.1', '-q' ])
subprocess.run([ which('pip'), 'install', 'httpx-retries==0.4.0', '-q' ])
+1 -1
View File
@@ -1,2 +1,2 @@
httpx==0.28.1
httpx-retries==0.4.0