revert some sstuff
Browse files- handler.py +10 -2
handler.py
CHANGED
@@ -7,9 +7,10 @@ class EndpointHandler:
|
|
7 |
_instance = None # Singleton instance
|
8 |
_model_loaded = False # Flag to check if the model is loaded
|
9 |
|
10 |
-
def __new__(cls):
|
11 |
if not cls._instance:
|
12 |
-
cls._instance = super(EndpointHandler, cls).__new__(cls)
|
|
|
13 |
return cls._instance
|
14 |
|
15 |
def __init__(self, model_path=""):
|
@@ -105,5 +106,12 @@ def main():
|
|
105 |
result_str = handler(data_str)
|
106 |
print("String input result:", result_str)
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
if __name__ == "__main__":
|
109 |
main()
|
|
|
7 |
_instance = None # Singleton instance
|
8 |
_model_loaded = False # Flag to check if the model is loaded
|
9 |
|
10 |
+
def __new__(cls, *args, **kwargs):
|
11 |
if not cls._instance:
|
12 |
+
cls._instance = super(EndpointHandler, cls).__new__(cls, *args, **kwargs)
|
13 |
+
cls._instance._model_loaded = False
|
14 |
return cls._instance
|
15 |
|
16 |
def __init__(self, model_path=""):
|
|
|
106 |
result_str = handler(data_str)
|
107 |
print("String input result:", result_str)
|
108 |
|
109 |
+
# Test 3: Invalid input type
|
110 |
+
data_invalid = 123
|
111 |
+
try:
|
112 |
+
handler(data_invalid)
|
113 |
+
except ValueError as e:
|
114 |
+
print("Invalid input type error:", e)
|
115 |
+
|
116 |
if __name__ == "__main__":
|
117 |
main()
|