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

Feature/buffer size #21

Merged
merged 7 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 13 additions & 3 deletions elx/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ def run(
streams: Optional[List[str]] = None,
logger: logging.Logger = None,
) -> None:
asyncio.run(self.async_run(streams=streams, logger=logger))
asyncio.get_event_loop().run_until_complete(
self.async_run(
streams=streams,
logger=logger,
)
)

async def async_run(
self,
Expand All @@ -90,8 +95,13 @@ def writelines(self, line: str):
if self.logger:
self.logger.info(line)

async with self.tap.process(state=state, streams=streams) as tap_process:
async with self.target.process(tap_process=tap_process) as target_process:
async with self.tap.process(
state=state,
streams=streams,
) as tap_process:
async with self.target.process(
tap_process=tap_process,
) as target_process:
tap_outputs = [target_process.stdin]
tap_stdout_future = asyncio.ensure_future(
# forward subproc stdout to tap_outputs (i.e. targets stdin)
Expand Down
1 change: 1 addition & 0 deletions elx/singer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from elx.utils import require_install, interpolate_in_config

PYTHON = "python3"
BUFFER_SIZE_LIMIT = 10485760


class Singer:
Expand Down
3 changes: 2 additions & 1 deletion elx/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from functools import cached_property
from pathlib import Path
from typing import Generator, List, Optional
from elx.singer import Singer, require_install
from elx.singer import Singer, require_install, BUFFER_SIZE_LIMIT
from elx.catalog import Stream, Catalog
from elx.json_temp_file import json_temp_file
from subprocess import Popen, PIPE
Expand Down Expand Up @@ -77,6 +77,7 @@ async def process(
],
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
limit=BUFFER_SIZE_LIMIT,
)

def invoke(
Expand Down
3 changes: 2 additions & 1 deletion elx/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import contextlib
from subprocess import PIPE, Popen
from typing import Generator, Optional
from elx.singer import Singer, require_install
from elx.singer import Singer, require_install, BUFFER_SIZE_LIMIT
from elx.json_temp_file import json_temp_file


Expand Down Expand Up @@ -35,4 +35,5 @@ async def process(
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
limit=BUFFER_SIZE_LIMIT,
)
1 change: 0 additions & 1 deletion tests/test_elx/test_tap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import pytest
from subprocess import Popen
from elx import Tap
from elx.catalog import Stream, Catalog

Expand Down
Loading