funboost 45.4__py3-none-any.whl → 45.7__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.

Potentially problematic release.


This version of funboost might be problematic. Click here for more details.

Files changed (74) hide show
  1. funboost/__init__.py +1 -1
  2. funboost/consumers/base_consumer.py +9 -3
  3. funboost/consumers/local_python_queue_consumer.py +2 -2
  4. funboost/core/current_task.py +1 -1
  5. funboost/core/func_params_model.py +2 -4
  6. funboost/function_result_web/__pycache__/functions.cpython-39.pyc +0 -0
  7. funboost/publishers/base_publisher.py +3 -0
  8. funboost/publishers/local_python_queue_publisher.py +8 -7
  9. funboost/queues/memory_queues_map.py +11 -0
  10. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-39.pyc +0 -0
  11. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-39.pyc +0 -0
  12. funboost/utils/dependency_packages_in_pythonpath/aioredis/__init__.py +59 -59
  13. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-39.pyc +0 -0
  14. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-39.pyc +0 -0
  15. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-39.pyc +0 -0
  16. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-39.pyc +0 -0
  17. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-39.pyc +0 -0
  18. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-39.pyc +0 -0
  19. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-39.pyc +0 -0
  20. funboost/utils/dependency_packages_in_pythonpath/aioredis/client.py +4804 -4804
  21. funboost/utils/dependency_packages_in_pythonpath/aioredis/compat.py +8 -8
  22. funboost/utils/dependency_packages_in_pythonpath/aioredis/connection.py +1668 -1668
  23. funboost/utils/dependency_packages_in_pythonpath/aioredis/exceptions.py +96 -96
  24. funboost/utils/dependency_packages_in_pythonpath/aioredis/lock.py +306 -306
  25. funboost/utils/dependency_packages_in_pythonpath/aioredis/log.py +15 -15
  26. funboost/utils/dependency_packages_in_pythonpath/aioredis/sentinel.py +329 -329
  27. funboost/utils/dependency_packages_in_pythonpath/aioredis/utils.py +61 -61
  28. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__init__.py +16 -16
  29. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-39.pyc +0 -0
  30. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-39.pyc +0 -0
  31. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-39.pyc +0 -0
  32. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-39.pyc +0 -0
  33. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-39.pyc +0 -0
  34. funboost/utils/dependency_packages_in_pythonpath/func_timeout/exceptions.py +98 -98
  35. funboost/utils/dependency_packages_in_pythonpath/func_timeout/py2_raise.py +7 -7
  36. funboost/utils/dependency_packages_in_pythonpath/func_timeout/py3_raise.py +7 -7
  37. funboost/utils/times/__init__.py +85 -85
  38. funboost/utils/times/version.py +1 -1
  39. {funboost-45.4.dist-info → funboost-45.7.dist-info}/METADATA +20 -10
  40. {funboost-45.4.dist-info → funboost-45.7.dist-info}/RECORD +44 -72
  41. {funboost-45.4.dist-info → funboost-45.7.dist-info}/entry_points.txt +0 -1
  42. funboost/function_result_web/__pycache__/app.cpython-37.pyc +0 -0
  43. funboost/function_result_web/__pycache__/functions.cpython-37.pyc +0 -0
  44. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-311.pyc +0 -0
  45. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-37.pyc +0 -0
  46. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-311.pyc +0 -0
  47. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-37.pyc +0 -0
  48. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-311.pyc +0 -0
  49. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-37.pyc +0 -0
  50. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-311.pyc +0 -0
  51. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-37.pyc +0 -0
  52. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-311.pyc +0 -0
  53. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-37.pyc +0 -0
  54. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-311.pyc +0 -0
  55. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-37.pyc +0 -0
  56. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-311.pyc +0 -0
  57. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-37.pyc +0 -0
  58. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-311.pyc +0 -0
  59. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-37.pyc +0 -0
  60. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-311.pyc +0 -0
  61. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-37.pyc +0 -0
  62. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-311.pyc +0 -0
  63. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-37.pyc +0 -0
  64. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-311.pyc +0 -0
  65. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-37.pyc +0 -0
  66. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-311.pyc +0 -0
  67. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-37.pyc +0 -0
  68. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-311.pyc +0 -0
  69. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-37.pyc +0 -0
  70. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-311.pyc +0 -0
  71. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-37.pyc +0 -0
  72. {funboost-45.4.dist-info → funboost-45.7.dist-info}/LICENSE +0 -0
  73. {funboost-45.4.dist-info → funboost-45.7.dist-info}/WHEEL +0 -0
  74. {funboost-45.4.dist-info → funboost-45.7.dist-info}/top_level.txt +0 -0
funboost/__init__.py CHANGED
@@ -13,7 +13,7 @@ set_frame_config这个模块的 use_config_form_funboost_config_module() 是核
13
13
  这段注释说明和使用的用户无关,只和框架开发人员有关.
14
14
  '''
15
15
 
16
- __version__ = "45.4"
16
+ __version__ = "45.7"
17
17
 
18
18
  from funboost.set_frame_config import show_frame_config
19
19
 
@@ -140,7 +140,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
140
140
  if consumer_params.consuming_function is None:
141
141
  raise ValueError('必须传 consuming_function 参数')
142
142
 
143
- self._msg_schedule_time_intercal = 0 if consumer_params.qps in (None,0) else 1.0 / consumer_params.qps
143
+ self._msg_schedule_time_intercal = 0 if consumer_params.qps in (None, 0) else 1.0 / consumer_params.qps
144
144
 
145
145
  self._concurrent_mode_dispatcher = ConcurrentModeDispatcher(self)
146
146
  if consumer_params.concurrent_mode == ConcurrentModeEnum.ASYNC:
@@ -233,6 +233,10 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
233
233
  self.logger.info(f'{self.queue_name} consumer 的消费者配置:\n {self.consumer_params.json_str_value()}')
234
234
  atexit.register(self.join_shedual_task_thread)
235
235
 
236
+ if self.consumer_params.is_auto_start_consuming_message:
237
+ _ = self.publisher_of_same_queue
238
+ self.start_consuming_message()
239
+
236
240
  def _build_logger(self):
237
241
  logger_prefix = self.consumer_params.logger_prefix
238
242
  if logger_prefix != '':
@@ -585,10 +589,12 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
585
589
  # method_cls = getattr(sys.modules[self.consumer_params.consuming_function_class_module],
586
590
  # self.consumer_params.consuming_function_class_name)
587
591
  if self.publisher_params.consuming_function_kind == FunctionKind.CLASS_METHOD:
588
- method_cls = getattr(PathHelper(method_first_param_value[ConstStrForClassMethod.CLS_FILE]).import_as_module(), method_first_param_value[ConstStrForClassMethod.CLS_NAME])
592
+ method_cls = getattr(PathHelper.import_module(method_first_param_value[ConstStrForClassMethod.CLS_MODULE]),
593
+ method_first_param_value[ConstStrForClassMethod.CLS_NAME])
589
594
  real_function_only_params[method_first_param_name] = method_cls
590
595
  elif self.publisher_params.consuming_function_kind == FunctionKind.INSTANCE_METHOD:
591
- method_cls = getattr(PathHelper(method_first_param_value[ConstStrForClassMethod.CLS_FILE]).import_as_module(), method_first_param_value[ConstStrForClassMethod.CLS_NAME])
596
+ method_cls = getattr(PathHelper.import_module(method_first_param_value[ConstStrForClassMethod.CLS_MODULE]),
597
+ method_first_param_value[ConstStrForClassMethod.CLS_NAME])
592
598
  obj = method_cls(**method_first_param_value[ConstStrForClassMethod.OBJ_INIT_PARAMS])
593
599
  real_function_only_params[method_first_param_name] = obj
594
600
  # print(real_function_only_params)
@@ -5,7 +5,7 @@ import json
5
5
  from queue import Queue,SimpleQueue
6
6
  from funboost.constant import BrokerEnum
7
7
  from funboost.consumers.base_consumer import AbstractConsumer
8
- from funboost.publishers import local_python_queue_publisher
8
+ from funboost.queues.memory_queues_map import PythonQueues
9
9
 
10
10
 
11
11
  class LocalPythonQueueConsumer(AbstractConsumer):
@@ -15,7 +15,7 @@ class LocalPythonQueueConsumer(AbstractConsumer):
15
15
 
16
16
  @property
17
17
  def local_python_queue(self) -> Queue:
18
- return local_python_queue_publisher.local_pyhton_queue_name__local_pyhton_queue_obj_map[self._queue_name]
18
+ return PythonQueues.get_queue(self._queue_name)
19
19
 
20
20
  def _shedual_task(self):
21
21
  while True:
@@ -163,7 +163,7 @@ def get_current_taskid():
163
163
  # return fct.function_result_status.task_id
164
164
  try:
165
165
  fct = funboost_current_task()
166
- return fct.task_id # 不在funboost的消费函数里面就获取不到上下文了
166
+ return fct.task_id # 不在funboost的消费函数里面或者同个线程、协程就获取不到上下文了
167
167
  except (AttributeError, LookupError) as e:
168
168
  # print(e,type(e))
169
169
  return 'no_task_id'
@@ -177,6 +177,7 @@ class BoosterParams(BaseJsonAbleModel):
177
177
  do_not_run_by_specify_time: tuple = ('10:00:00', '22:00:00') # 不运行的时间段,在这个时间段自动不运行函数.
178
178
 
179
179
  schedule_tasks_on_main_thread: bool = False # 直接在主线程调度任务,意味着不能直接在当前主线程同时开启两个消费者。
180
+ is_auto_start_consuming_message: bool = False # 是否在定义后就自动启动消费,无需用户手动写 .consume() 来启动消息消费。
180
181
 
181
182
  consuming_function: typing.Callable = None # 消费函数,在@boost时候不用指定,因为装饰器知道下面的函数.
182
183
  consuming_function_raw: typing.Callable = None
@@ -195,8 +196,7 @@ class BoosterParams(BaseJsonAbleModel):
195
196
 
196
197
  auto_generate_info: dict = {} # 自动生成的信息,不需要用户主动传参.
197
198
 
198
- consuming_function_kind :typing.Optional[str]= None #自动生成的信息,不需要用户主动传参.
199
-
199
+ consuming_function_kind: typing.Optional[str] = None # 自动生成的信息,不需要用户主动传参,如果自动判断失误就传递。
200
200
 
201
201
  @root_validator(skip_on_failure=True)
202
202
  def check_values(cls, values: dict):
@@ -269,7 +269,6 @@ class PriorityConsumingControlConfig(BaseJsonAbleModel):
269
269
  misfire_grace_time: typing.Union[int, None] = None
270
270
  other_extra_params: dict = None # 其他参数, 例如消息优先级 , priority_control_config=PriorityConsumingControlConfig(other_extra_params={'priroty': priorityxx}),
271
271
 
272
-
273
272
  @root_validator(skip_on_failure=True)
274
273
  def cehck_values(cls, values: dict):
275
274
  if values['countdown'] and values['eta']:
@@ -297,7 +296,6 @@ class PublisherParams(BaseJsonAbleModel):
297
296
  consuming_function_kind: typing.Optional[str] = None # 自动生成的信息,不需要用户主动传参.
298
297
 
299
298
 
300
-
301
299
  if __name__ == '__main__':
302
300
  from funboost.concurrent_pool import FlexibleThreadPool
303
301
 
@@ -33,6 +33,7 @@ from funboost.core.serialization import Serialization
33
33
  from funboost.core.task_id_logger import TaskIdLogger
34
34
  from funboost.utils import decorators
35
35
  from funboost.funboost_config_deafult import BrokerConnConfig, FunboostCommonConfig
36
+ from nb_libs.path_helper import PathHelper
36
37
 
37
38
  RedisAsyncResult = AsyncResult # 别名
38
39
  RedisAioAsyncResult = AioAsyncResult # 别名
@@ -271,6 +272,7 @@ class AbstractPublisher(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
271
272
  func_args_list[0] = {ConstStrForClassMethod.FIRST_PARAM_NAME: self.publish_params_checker.all_arg_name[0],
272
273
  ConstStrForClassMethod.CLS_NAME: cls.__name__,
273
274
  ConstStrForClassMethod.CLS_FILE: self.__get_cls_file(cls),
275
+ ConstStrForClassMethod.CLS_MODULE: PathHelper(self.__get_cls_file(cls)).get_module_name(),
274
276
  }
275
277
  elif self.publisher_params.consuming_function_kind == FunctionKind.INSTANCE_METHOD:
276
278
  obj = func_args[0]
@@ -280,6 +282,7 @@ class AbstractPublisher(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
280
282
  func_args_list[0] = {ConstStrForClassMethod.FIRST_PARAM_NAME: self.publish_params_checker.all_arg_name[0],
281
283
  ConstStrForClassMethod.CLS_NAME: cls.__name__,
282
284
  ConstStrForClassMethod.CLS_FILE: self.__get_cls_file(cls),
285
+ ConstStrForClassMethod.CLS_MODULE: PathHelper(self.__get_cls_file(cls)).get_module_name(),
283
286
  ConstStrForClassMethod.OBJ_INIT_PARAMS: getattr(obj, ConstStrForClassMethod.OBJ_INIT_PARAMS),
284
287
 
285
288
  }
@@ -5,6 +5,7 @@ from collections import deque
5
5
  from queue import Queue, SimpleQueue
6
6
 
7
7
  from funboost.publishers.base_publisher import AbstractPublisher
8
+ from funboost.queues.memory_queues_map import PythonQueues
8
9
 
9
10
  local_pyhton_queue_name__local_pyhton_queue_obj_map = dict() # 使local queue和其他中间件完全一样的使用方式,使用映射保存队列的名字,使消费和发布通过队列名字能找到队列对象。
10
11
 
@@ -15,23 +16,23 @@ class LocalPythonQueuePublisher(AbstractPublisher):
15
16
  """
16
17
 
17
18
  # noinspection PyAttributeOutsideInit
18
- def custom_init(self):
19
- if self._queue_name not in local_pyhton_queue_name__local_pyhton_queue_obj_map:
20
- local_pyhton_queue_name__local_pyhton_queue_obj_map[self._queue_name] = Queue(1000000)
21
- self.queue = local_pyhton_queue_name__local_pyhton_queue_obj_map[self._queue_name]
19
+
20
+ @property
21
+ def local_python_queue(self) -> Queue:
22
+ return PythonQueues.get_queue(self._queue_name)
22
23
 
23
24
  def concrete_realization_of_publish(self, msg):
24
25
  # noinspection PyTypeChecker
25
26
  pass
26
- self.queue.put(msg)
27
+ self.local_python_queue.put(msg)
27
28
 
28
29
  def clear(self):
29
30
  # noinspection PyUnresolvedReferences
30
- self.queue.queue.clear()
31
+ self.local_python_queue.queue.clear()
31
32
  self.logger.warning(f'清除 本地队列中的消息成功')
32
33
 
33
34
  def get_message_count(self):
34
- return self.queue.qsize()
35
+ return self.local_python_queue.qsize()
35
36
 
36
37
  def close(self):
37
38
  pass
@@ -0,0 +1,11 @@
1
+ import queue
2
+
3
+
4
+ class PythonQueues:
5
+ local_pyhton_queue_name__local_pyhton_queue_obj_map = {}
6
+
7
+ @classmethod
8
+ def get_queue(cls,queue_name):
9
+ if queue_name not in cls.local_pyhton_queue_name__local_pyhton_queue_obj_map:
10
+ cls.local_pyhton_queue_name__local_pyhton_queue_obj_map[queue_name] = queue.Queue()
11
+ return cls.local_pyhton_queue_name__local_pyhton_queue_obj_map[queue_name]
@@ -1,59 +1,59 @@
1
- from aioredis.client import Redis, StrictRedis
2
- from aioredis.connection import (
3
- BlockingConnectionPool,
4
- Connection,
5
- ConnectionPool,
6
- SSLConnection,
7
- UnixDomainSocketConnection,
8
- )
9
- from aioredis.exceptions import (
10
- AuthenticationError,
11
- AuthenticationWrongNumberOfArgsError,
12
- BusyLoadingError,
13
- ChildDeadlockedError,
14
- ConnectionError,
15
- DataError,
16
- InvalidResponse,
17
- PubSubError,
18
- ReadOnlyError,
19
- RedisError,
20
- ResponseError,
21
- TimeoutError,
22
- WatchError,
23
- )
24
- from aioredis.utils import from_url
25
-
26
-
27
- def int_or_str(value):
28
- try:
29
- return int(value)
30
- except ValueError:
31
- return value
32
-
33
-
34
- __version__ = "2.0.1"
35
- VERSION = tuple(map(int_or_str, __version__.split(".")))
36
-
37
- __all__ = [
38
- "AuthenticationError",
39
- "AuthenticationWrongNumberOfArgsError",
40
- "BlockingConnectionPool",
41
- "BusyLoadingError",
42
- "ChildDeadlockedError",
43
- "Connection",
44
- "ConnectionError",
45
- "ConnectionPool",
46
- "DataError",
47
- "from_url",
48
- "InvalidResponse",
49
- "PubSubError",
50
- "ReadOnlyError",
51
- "Redis",
52
- "RedisError",
53
- "ResponseError",
54
- "SSLConnection",
55
- "StrictRedis",
56
- "TimeoutError",
57
- "UnixDomainSocketConnection",
58
- "WatchError",
59
- ]
1
+ from aioredis.client import Redis, StrictRedis
2
+ from aioredis.connection import (
3
+ BlockingConnectionPool,
4
+ Connection,
5
+ ConnectionPool,
6
+ SSLConnection,
7
+ UnixDomainSocketConnection,
8
+ )
9
+ from aioredis.exceptions import (
10
+ AuthenticationError,
11
+ AuthenticationWrongNumberOfArgsError,
12
+ BusyLoadingError,
13
+ ChildDeadlockedError,
14
+ ConnectionError,
15
+ DataError,
16
+ InvalidResponse,
17
+ PubSubError,
18
+ ReadOnlyError,
19
+ RedisError,
20
+ ResponseError,
21
+ TimeoutError,
22
+ WatchError,
23
+ )
24
+ from aioredis.utils import from_url
25
+
26
+
27
+ def int_or_str(value):
28
+ try:
29
+ return int(value)
30
+ except ValueError:
31
+ return value
32
+
33
+
34
+ __version__ = "2.0.1"
35
+ VERSION = tuple(map(int_or_str, __version__.split(".")))
36
+
37
+ __all__ = [
38
+ "AuthenticationError",
39
+ "AuthenticationWrongNumberOfArgsError",
40
+ "BlockingConnectionPool",
41
+ "BusyLoadingError",
42
+ "ChildDeadlockedError",
43
+ "Connection",
44
+ "ConnectionError",
45
+ "ConnectionPool",
46
+ "DataError",
47
+ "from_url",
48
+ "InvalidResponse",
49
+ "PubSubError",
50
+ "ReadOnlyError",
51
+ "Redis",
52
+ "RedisError",
53
+ "ResponseError",
54
+ "SSLConnection",
55
+ "StrictRedis",
56
+ "TimeoutError",
57
+ "UnixDomainSocketConnection",
58
+ "WatchError",
59
+ ]