Skip to content

Commit 6d49e47

Browse files
committed
chore: protect against calls where Session isnt fully initialized
1 parent 7d68d53 commit 6d49e47

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bigframes/core/log_adapter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ def add_api_method(api_method_name, session=None):
258258

259259
clean_method_name = api_method_name.replace("<", "").replace(">", "")
260260

261-
if session is not None:
261+
# The log adapter can get called before the Session has fully initialized.
262+
if session is not None and hasattr(session, "_api_methods_lock"):
262263
with session._api_methods_lock:
263264
session._api_methods.insert(0, clean_method_name)
264265
session._api_methods = session._api_methods[:MAX_LABELS_COUNT]
@@ -273,7 +274,9 @@ def add_api_method(api_method_name, session=None):
273274
def get_and_reset_api_methods(dry_run: bool = False, session=None):
274275
global _lock
275276
methods = []
276-
if session is not None:
277+
278+
# The log adapter can get called before the Session has fully initialized.
279+
if session is not None and hasattr(session, "_api_methods_lock"):
277280
with session._api_methods_lock:
278281
methods.extend(session._api_methods)
279282
if not dry_run:

0 commit comments

Comments
 (0)