Skip to content

Commit 134bfe9

Browse files
tauhid621claude
andauthored
test(bigquery): fix and re-enable query-cancellation test (#2063)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9fce78f commit 134bfe9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

dbt-bigquery/tests/functional/test_cancel.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010

1111
from dbt.tests.util import get_connection
1212

13+
14+
def _reset_sigint_in_child():
15+
"""Un-ignore SIGINT in the dbt child so it can be cancelled via Ctrl-C.
16+
17+
pytest-xdist workers set SIGINT to SIG_IGN, and that "ignore" state is
18+
inherited by the child across exec. CPython skips installing its
19+
KeyboardInterrupt handler when SIGINT arrives already ignored, so dbt would
20+
silently drop the SIGINT this test sends. Resetting to SIG_DFL here (in the
21+
child, before exec) lets dbt install its normal handler and cancel.
22+
"""
23+
signal.signal(signal.SIGINT, signal.SIG_DFL)
24+
25+
1326
_SEED_CSV = """
1427
id, name, astrological_sign, moral_alignment
1528
1, Alice, Aries, Lawful Good
@@ -77,6 +90,7 @@ def _run_dbt_in_subprocess(project, dbt_command):
7790
stderr=subprocess.PIPE,
7891
shell=False,
7992
env=os.environ.copy(),
93+
preexec_fn=_reset_sigint_in_child,
8094
)
8195
std_out_log = ""
8296
while True:
@@ -104,7 +118,6 @@ def _get_job_id(project, table_name):
104118
return job_id
105119

106120

107-
@pytest.mark.skip(reason="flaky in CI: subprocess signal timing is unreliable")
108121
@pytest.mark.skipif(
109122
platform.system() == "Windows", reason="running signt is unsupported on Windows."
110123
)

0 commit comments

Comments
 (0)