Skip to content

Commit

Permalink
make sure its in same event loop (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo committed Apr 29, 2024
1 parent 72ddb0d commit c54cc72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions datadog_sync/utils/base_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class ResourceConfig:
tagging_config: Optional[TaggingConfig] = None
async_lock: Optional[Lock] = None

async def init_async(self) -> None:
self.async_lock = Lock()

def __post_init__(self) -> None:
self.build_excluded_attributes()
if not self.concurrent:
Expand All @@ -84,6 +87,9 @@ def __init__(self, config: Configuration) -> None:
self.resource_type
)

async def init_async(self):
await self.resource_config.init_async()

@abc.abstractmethod
async def get_resources(self, client: CustomClient) -> List[Dict]:
pass
Expand Down
2 changes: 2 additions & 0 deletions datadog_sync/utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class Configuration(object):
async def init_async(self, cmd: Command):
await self.source_client._init_session()
await self.destination_client._init_session()
for resource in self.resources.values():
await resource.init_async()

# Validate the clients. For import we only validate the source client
# For sync/diffs we validate the destination client.
Expand Down

0 comments on commit c54cc72

Please sign in to comment.