Skip to content

Commit 63fbd7e

Browse files
fix: bypass PrintBuffer in launch() to prevent RLock deadlock
PrintBuffer.flush() writes directly to sys.__stdout__ while holding an RLock. When the platform pauses reading stdout, flush() blocks on the pipe and the lock is never released. Every other thread that calls logger.info() then blocks waiting for the same RLock, causing a process-wide deadlock. Removing the 'with PRINT_BUFFER:' wrapper means print() and logging go directly to stdout/stderr without the shared lock, allowing the stdout writer thread to be the only bottleneck on the pipe. Co-Authored-By: unknown <>
1 parent 059fd36 commit 63fbd7e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

airbyte_cdk/entrypoint.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from airbyte_cdk.connector import TConfig
2626
from airbyte_cdk.exception_handler import init_uncaught_exception_handler
27-
from airbyte_cdk.logger import PRINT_BUFFER, init_logger, is_platform_debug_log_enabled
27+
from airbyte_cdk.logger import init_logger, is_platform_debug_log_enabled
2828
from airbyte_cdk.models import (
2929
AirbyteConnectionStatus,
3030
AirbyteMessage,
@@ -373,10 +373,13 @@ def _emit_queued_messages(self, source: Source) -> Iterable[AirbyteMessage]:
373373
def launch(source: Source, args: List[str]) -> None:
374374
source_entrypoint = AirbyteEntrypoint(source)
375375
parsed_args = source_entrypoint.parse_args(args)
376-
# temporarily removes the PrintBuffer because we're seeing weird print behavior for concurrent syncs
377-
# Refer to: https://github.com/airbytehq/oncall/issues/6235
378-
with PRINT_BUFFER:
379-
_buffered_write_to_stdout(source_entrypoint.run(parsed_args))
376+
# PrintBuffer is intentionally NOT used here. Its RLock + blocking
377+
# sys.__stdout__.write() in flush() causes a process-wide deadlock
378+
# when the platform pauses reading from stdout: the thread that holds
379+
# the lock blocks on the pipe, and every other thread that tries to
380+
# log also blocks waiting for the same lock.
381+
# See: https://github.com/airbytehq/oncall/issues/6235
382+
_buffered_write_to_stdout(source_entrypoint.run(parsed_args))
380383

381384

382385
def _buffered_write_to_stdout(messages: Iterable[str]) -> None:

0 commit comments

Comments
 (0)