Skip to content

Commit d7b0378

Browse files
committed
Review fixes
1 parent 44068e9 commit d7b0378

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/guidellm/utils/pydantic_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929

3030
BaseModelT = TypeVar("BaseModelT", bound=BaseModel)
31-
T = TypeVar("T", bound=BaseModel)
3231
SuccessfulT = TypeVar("SuccessfulT")
3332
ErroredT = TypeVar("ErroredT")
3433
IncompleteT = TypeVar("IncompleteT")
@@ -90,7 +89,7 @@ class MyModel(StandardBaseModel):
9089
)
9190

9291
@classmethod
93-
def get_default(cls: type[T], field: str) -> Any:
92+
def get_default(cls: type[BaseModelT], field: str) -> Any:
9493
"""
9594
Get default value for a model field.
9695

src/guidellm/utils/singleton.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ def __new__(cls, *args, **kwargs): # noqa: ARG004
9494
lock_attr_name = f"_singleton_lock_{cls.__name__}"
9595
instance_attr_name = f"_singleton_instance_{cls.__name__}"
9696

97-
if not hasattr(cls, lock_attr_name):
98-
setattr(cls, lock_attr_name, threading.Lock())
99-
10097
with getattr(cls, lock_attr_name):
10198
instance_exists = (
10299
hasattr(cls, instance_attr_name)
@@ -109,6 +106,11 @@ def __new__(cls, *args, **kwargs): # noqa: ARG004
109106
instance._init_lock = threading.Lock()
110107
return getattr(cls, instance_attr_name)
111108

109+
def __init_subclass__(cls, *args, **kwargs):
110+
super().__init_subclass__(*args, **kwargs)
111+
lock_attr_name = f"_singleton_lock_{cls.__name__}"
112+
setattr(cls, lock_attr_name, threading.Lock())
113+
112114
def __init__(self):
113115
"""Initialize the singleton instance with thread-safe initialization."""
114116
with self._init_lock:

0 commit comments

Comments
 (0)