Skip to content

Commit beadfe5

Browse files
authored
Don't complain about uninitialized plugs in StationServer logs (#991)
StationServer seems to be trying to represent (as base type) phase sequences that don't yet have their plugs initialized. This causes a warning to be logged like ``` WARNING:root:Object <class 'my.custom.htf.Plug'> is not initialized, got error _asdict() missing 1 required positional argument: 'self' ``` But has no other effect. The call stack when that warning is reached is ``` convert_to_base_types (data.py:176) <dictcomp> (data.py:199) convert_to_base_types (data.py:201) <listcomp> (data.py:204) convert_to_base_types (data.py:206) <dictcomp> (data.py:199) convert_to_base_types (data.py:201) <listcomp> (station_server.py:364) get (station_server.py:364) _execute (web.py:1702) _run (events.py:145) _run_once (base_events.py:1451) run_forever (base_events.py:438) start (asyncio.py:199) run (web_gui_server.py:157) run (station_server.py:626) _bootstrap_inner (threading.py:916) _bootstrap (threading.py:884) ``` This PR removes that warning, behaviour remains the same.
1 parent e9d7365 commit beadfe5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

openhtf/util/data.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import difflib
2323
import enum
2424
import itertools
25+
import inspect
2526
import logging
2627
import math
2728
import numbers
@@ -163,13 +164,8 @@ def convert_to_base_types(obj,
163164

164165
if hasattr(obj, 'as_base_types'):
165166
return obj.as_base_types()
166-
if hasattr(obj, '_asdict'):
167-
try:
168-
obj = obj._asdict()
169-
except TypeError as e:
170-
# This happens if the object is an uninitialized class.
171-
logging.warning(
172-
'Object %s is not initialized, got error %s', obj, e)
167+
if hasattr(obj, '_asdict') and not inspect.isclass(obj):
168+
obj = obj._asdict()
173169
elif isinstance(obj, records.RecordClass):
174170
new_obj = {}
175171
for a in type(obj).all_attribute_names:

0 commit comments

Comments
 (0)