potiuk commented on code in PR #38707:
URL: https://github.com/apache/airflow/pull/38707#discussion_r1560844228
##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -111,6 +112,15 @@ def fetch_one_handler(cursor) -> list[tuple] | None:
return None
+@contextmanager
+def suppress_and_warn(*exceptions: type[BaseException]):
+ """Context manager that suppresses the given exceptions and logs a warning
message."""
+ try:
+ yield
+ except exceptions as e:
+ warnings.warn(f"Exception suppressed: {e}\n{traceback.format_exc()}",
category=UserWarning)
+
+
Review Comment:
Yes, that was the idea of my intial proposal - to move it there as it would
be immediately useful for all those 24 providers.
And yes - I agree with @Taragolis that this is more suitable for
`common.utils` or whatever we might come up with - but well, we do not have
`common.utils` yet nor even the consensus of whether we need it and how to
manage it. There was some vague idea about polyfills in the devlist discuussion
(but I have no idea how to do it in the Python world and what it means for our
build and release process).
So we have no "perfect" solution - we have only "so-so" ones.
1) make it non-DRY and copy
2) reuse it via common.sql
3) (most complex) agree to, create and use `common.utils`
I am good with all three approaches. As long as someone will take on the 3)
and prepares and takes lead of common.utils - I think it's the right time I
stop leading and implementing this all myself.
I guess @Taragolis - pick your poison.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]