Skip to content

Commit e016621

Browse files
committed
use wrapt_timeout_decorator library for process-based timeouts
1 parent fb384ad commit e016621

File tree

3 files changed

+5
-56
lines changed

3 files changed

+5
-56
lines changed

metadata-ingestion/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
# Using an Acryl fork of sqlglot.
9696
# https://github.com/tobymao/sqlglot/compare/main...hsheth2:sqlglot:hsheth?expand=1
9797
"acryl-sqlglot==21.1.2.dev9",
98+
"wrapt_timeout_decorator",
9899
}
99100

100101
sql_common = (

metadata-ingestion/src/datahub/sql_parsing/sqlglot_lineage.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sqlglot.optimizer.annotate_types
1313
import sqlglot.optimizer.optimizer
1414
import sqlglot.optimizer.qualify
15+
import wrapt_timeout_decorator
1516

1617
from datahub.cli.env_utils import get_boolean_env_variable
1718
from datahub.ingestion.graph.client import DataHubGraph
@@ -45,7 +46,6 @@
4546
is_dialect_instance,
4647
parse_statement,
4748
)
48-
from datahub.utilities.timeout import timeout
4949

5050
logger = logging.getLogger(__name__)
5151

@@ -311,6 +311,9 @@ class SqlUnderstandingError(Exception):
311311

312312

313313
# TODO: Break this up into smaller functions.
314+
@wrapt_timeout_decorator.timeout(
315+
SQL_LINEAGE_TIMEOUT_SECONDS if SQL_LINEAGE_TIMEOUT_ENABLED else None,
316+
)
314317
def _column_level_lineage( # noqa: C901
315318
statement: sqlglot.exp.Expression,
316319
dialect: sqlglot.Dialect,
@@ -766,7 +769,6 @@ def _translate_internal_column_lineage(
766769
)
767770

768771

769-
@timeout(enabled=SQL_LINEAGE_TIMEOUT_ENABLED, seconds=SQL_LINEAGE_TIMEOUT_SECONDS)
770772
def _sqlglot_lineage_inner(
771773
sql: sqlglot.exp.ExpOrStr,
772774
schema_resolver: SchemaResolverInterface,

metadata-ingestion/src/datahub/utilities/timeout.py

-54
This file was deleted.

0 commit comments

Comments
 (0)