From 0ab460550eb726d415287ca0ddfed0da45cd2979 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Fri, 26 Apr 2024 16:34:36 +0200 Subject: [PATCH] Add sleep to avoid race condition when importing products --- gso/cli/imports.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 6967eb2d..014781cb 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -3,6 +3,7 @@ import csv import ipaddress import json +import time from datetime import UTC, datetime from pathlib import Path from typing import Any, TypeVar @@ -225,6 +226,9 @@ def _generic_import_product( except ValidationError as e: typer.echo(f"Validation error: {e}") + typer.echo("Waiting for the dust to settle before moving on the importing new products...") + time.sleep(1) + # Migrate new products from imported to "full" counterpart. imported_products = get_subscriptions( [imported_product_type], lifecycles=[SubscriptionLifecycle.ACTIVE], includes=["subscription_id"] @@ -331,6 +335,9 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") + typer.echo("Waiting for the dust to settle before moving on the importing new products...") + time.sleep(1) + trunk_ids = get_subscriptions( [ProductType.IMPORTED_IP_TRUNK], lifecycles=[SubscriptionLifecycle.ACTIVE], includes=["subscription_id"] ) -- GitLab