Skip to content

Commit e333a9b

Browse files
committed
fix
1 parent 59c0ec5 commit e333a9b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

bigframes/blob/_functions.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,29 @@ def _cleanup_old_udfs(self):
7878
datetime.timezone.utc
7979
) - datetime.timedelta(days=_UDF_CLEANUP_THRESHOLD_DAYS)
8080

81-
cleaned_up_routines = 0
8281
for routine in routines:
8382
if (
8483
routine.created < seven_days_ago
8584
and routine._properties["routineType"] == "SCALAR_FUNCTION"
8685
):
87-
self._session.bqclient.delete_routine(routine.reference)
88-
cleaned_up_routines += 1
86+
try:
87+
self._session.bqclient.delete_routine(routine.reference)
88+
except Exception:
89+
pass
8990

9091
def _create_udf(self):
9192
"""Create Python UDF in BQ. Return name of the UDF."""
9293
udf_name = str(
9394
self._session._anon_dataset_manager.generate_unique_resource_id()
9495
)
9596

96-
# Try to clean up the old Python UDFs in the anonymous dataset. Do not
97-
# raise an error when it fails for this step.
97+
# Try to clean up the old Python UDFs in the anonymous dataset. Failure
98+
# to clean up is logged as a warning but does not halt execution.
9899
try:
100+
# Before creating a new UDF, attempt to clean up any uncollected,
101+
# old Python UDFs residing in the anonymous dataset. These UDFs
102+
# accumulate over time and can eventually exceed resource limits.
103+
# See more from b/450913424.
99104
self._cleanup_old_udfs()
100105
except Exception as e:
101106
msg = bfe.format_message(

0 commit comments

Comments
 (0)