File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments