Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(target): Turn drain_one into a async method #2289

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions singer_sdk/target_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import abc
import asyncio
import copy
import json
import sys
Expand Down Expand Up @@ -368,7 +369,7 @@
sink.stream_name,
sink.current_size,
)
self.drain_one(sink)
asyncio.run(self.drain_one(sink))

Check warning on line 372 in singer_sdk/target_base.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/target_base.py#L372

Added line #L372 was not covered by tests

self._handle_max_record_age()

Expand Down Expand Up @@ -497,7 +498,7 @@
self._reset_max_record_age()

@t.final
def drain_one(self, sink: Sink) -> None:
async def drain_one(self, sink: Sink) -> None:
"""Drain a specific sink.

This method is internal to the SDK and should not need to be overridden.
Expand All @@ -519,7 +520,7 @@
return

def _drain_sink(sink: Sink) -> None:
self.drain_one(sink)
asyncio.run(self.drain_one(sink))

with parallel_config(backend="threading", n_jobs=parallelism):
Parallel()(delayed(_drain_sink)(sink=sink) for sink in sink_list)
Expand Down
Loading