libentry 1.26__py3-none-any.whl → 1.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
libentry/mcp/service.py CHANGED
@@ -10,7 +10,7 @@ from dataclasses import dataclass
10
10
  from queue import Empty, Queue
11
11
  from threading import Lock
12
12
  from types import GeneratorType
13
- from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional, Tuple, Type, Union
13
+ from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional, Tuple, Union
14
14
 
15
15
  from flask import Flask, request as flask_request
16
16
  from pydantic import BaseModel, Field, TypeAdapter
@@ -891,19 +891,41 @@ class GunicornApplication(BaseApplication):
891
891
 
892
892
  def load(self):
893
893
  logger.info("Initializing the service.")
894
- if isinstance(self.service_type, type) or callable(self.service_type):
895
- service = self.service_type(self.service_config) if self.service_config else self.service_type()
896
- elif self.service_config is None:
894
+ if isinstance(self.service_type, (List, Tuple)):
895
+ if isinstance(self.service_config, (List, Tuple)) and len(self.service_config) == len(self.service_type):
896
+ service = [
897
+ self._create_service(t, c)
898
+ for t, c in zip(self.service_type, self.service_config)
899
+ ]
900
+ elif self.service_config is None:
901
+ service = [
902
+ self._create_service(t, self.service_config)
903
+ for t in self.service_type
904
+ ]
905
+ else:
906
+ raise RuntimeError(
907
+ f"You are going to run {len(self.service_type)} services. "
908
+ "In the multiple service mode, every `service_type` requires a `service_config` object."
909
+ )
910
+ else:
911
+ service = self._create_service(self.service_type, self.service_config)
912
+ logger.info("Service initialized.")
913
+
914
+ return FlaskServer(service)
915
+
916
+ @staticmethod
917
+ def _create_service(service_type, service_config):
918
+ if isinstance(service_type, type) or callable(service_type):
919
+ service = service_type(service_config) if service_config else service_type()
920
+ elif service_config is None:
897
921
  logger.warning(
898
922
  "Be careful! It is not recommended to start the server from a service instance. "
899
923
  "Use service_type and service_config instead."
900
924
  )
901
- service = self.service_type
925
+ service = service_type
902
926
  else:
903
- raise TypeError(f"Invalid service type \"{type(self.service_type)}\".")
904
- logger.info("Service initialized.")
905
-
906
- return FlaskServer(service)
927
+ raise TypeError(f"Invalid service type \"{type(service_type)}\".")
928
+ return service
907
929
 
908
930
 
909
931
  class RunServiceConfig(BaseModel):
@@ -969,7 +991,7 @@ class RunServiceConfig(BaseModel):
969
991
 
970
992
 
971
993
  def run_service(
972
- service_type: Union[Type, Callable],
994
+ service_type: Union[Union[type, Callable], List, Tuple],
973
995
  service_config=None,
974
996
  run_config: Optional[RunServiceConfig] = None,
975
997
  *,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: libentry
3
- Version: 1.26
3
+ Version: 1.27
4
4
  Summary: Entries for experimental utilities.
5
5
  Home-page: https://github.com/XoriieInpottn/libentry
6
6
  Author: xi
@@ -13,7 +13,7 @@ libentry/utils.py,sha256=vCm6UyAlibnPOlPJHZO57u3TXhw5PZmGM5_vBAPUnB4,1981
13
13
  libentry/mcp/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
14
14
  libentry/mcp/api.py,sha256=GDErVCz_hh_ZeMxLS8bTPyBUhCTHw3Mm-nGFMV2W2yo,3669
15
15
  libentry/mcp/client.py,sha256=qFbigNIOJvEf8ZICN2K8nnmVcITIzDhJgaw3c0P-WXM,23078
16
- libentry/mcp/service.py,sha256=PpdQBxqKPiZ2tpnsqDYiC29_yjMjK9J3VWynn4uvpVg,38109
16
+ libentry/mcp/service.py,sha256=YMzP9sTR6RaeguwbwapFZFcc7MjKuDDfpeXSCD09Xzg,39081
17
17
  libentry/mcp/types.py,sha256=aAoVO4jjqEvDzNneuZapmRYonLLnGsbcLoypVyRNNYg,12389
18
18
  libentry/service/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
19
19
  libentry/service/common.py,sha256=OVaW2afgKA6YqstJmtnprBCqQEUZEWotZ6tHavmJJeU,42
@@ -22,10 +22,10 @@ libentry/service/list.py,sha256=ElHWhTgShGOhaxMUEwVbMXos0NQKjHsODboiQ-3AMwE,1397
22
22
  libentry/service/running.py,sha256=FrPJoJX6wYxcHIysoatAxhW3LajCCm0Gx6l7__6sULQ,5105
23
23
  libentry/service/start.py,sha256=mZT7b9rVULvzy9GTZwxWnciCHgv9dbGN2JbxM60OMn4,1270
24
24
  libentry/service/stop.py,sha256=wOpwZgrEJ7QirntfvibGq-XsTC6b3ELhzRW2zezh-0s,1187
25
- libentry-1.26.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
- libentry-1.26.dist-info/METADATA,sha256=FhTlnziZK-JqX2iRA3i4p0Oz9cQviwQV1dwmhz6Cxs0,1133
27
- libentry-1.26.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
28
- libentry-1.26.dist-info/entry_points.txt,sha256=1v_nLVDsjvVJp9SWhl4ef2zZrsLTBtFWgrYFgqvQBgc,61
29
- libentry-1.26.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
30
- libentry-1.26.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
31
- libentry-1.26.dist-info/RECORD,,
25
+ libentry-1.27.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
+ libentry-1.27.dist-info/METADATA,sha256=4Kmb2RNxxAYb26wbovxkx8haDAaW7tBg_JEuxPwkwuI,1133
27
+ libentry-1.27.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
28
+ libentry-1.27.dist-info/entry_points.txt,sha256=1v_nLVDsjvVJp9SWhl4ef2zZrsLTBtFWgrYFgqvQBgc,61
29
+ libentry-1.27.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
30
+ libentry-1.27.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
31
+ libentry-1.27.dist-info/RECORD,,