funboost 49.8__py3-none-any.whl → 49.9__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 (36) hide show
  1. funboost/__init__.py +1 -1
  2. funboost/assist/celery_helper.py +1 -1
  3. funboost/concurrent_pool/async_pool_executor.py +7 -2
  4. funboost/constant.py +23 -0
  5. funboost/consumers/base_consumer.py +12 -7
  6. funboost/consumers/grpc_consumer.py +102 -0
  7. funboost/consumers/kafka_consumer.py +4 -2
  8. funboost/consumers/kafka_consumer_manually_commit.py +7 -2
  9. funboost/consumers/mysql_cdc_consumer.py +95 -0
  10. funboost/contrib/cdc/__init__.py +0 -0
  11. funboost/contrib/cdc/mysql2mysql.py +44 -0
  12. funboost/core/booster.py +25 -2
  13. funboost/core/exceptions.py +3 -0
  14. funboost/core/func_params_model.py +6 -5
  15. funboost/core/msg_result_getter.py +8 -7
  16. funboost/factories/broker_kind__publsiher_consumer_type_map.py +10 -1
  17. funboost/publishers/base_publisher.py +5 -6
  18. funboost/publishers/grpc_publisher.py +53 -0
  19. funboost/publishers/kafka_publisher.py +3 -1
  20. funboost/publishers/mysql_cdc_publisher.py +24 -0
  21. funboost/timing_job/timing_push.py +3 -1
  22. {funboost-49.8.dist-info → funboost-49.9.dist-info}/METADATA +69 -33
  23. {funboost-49.8.dist-info → funboost-49.9.dist-info}/RECORD +27 -30
  24. funboost/utils/class_utils2.py +0 -94
  25. funboost/utils/custom_pysnooper.py +0 -149
  26. funboost/utils/pysnooper_ydf/__init__.py +0 -32
  27. funboost/utils/pysnooper_ydf/pycompat.py +0 -82
  28. funboost/utils/pysnooper_ydf/tracer.py +0 -479
  29. funboost/utils/pysnooper_ydf/utils.py +0 -101
  30. funboost/utils/pysnooper_ydf/variables.py +0 -133
  31. funboost/utils/times/__init__.py +0 -85
  32. funboost/utils/times/version.py +0 -1
  33. {funboost-49.8.dist-info → funboost-49.9.dist-info}/LICENSE +0 -0
  34. {funboost-49.8.dist-info → funboost-49.9.dist-info}/WHEEL +0 -0
  35. {funboost-49.8.dist-info → funboost-49.9.dist-info}/entry_points.txt +0 -0
  36. {funboost-49.8.dist-info → funboost-49.9.dist-info}/top_level.txt +0 -0
@@ -1,149 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # @Author : ydf
3
- """
4
- 基于0.0.11版本,对其打猴子补丁改进的。现在推荐使用pysnooper_ydf里面的,不需要用这里。
5
- DeBug Python代码全靠print函数?换用这个一天2K+Star的工具吧
6
- 对最火热的github库,进行了三点改造。
7
- 1、由于部署一般是linux,开发是windows,所以可以自动使其在linux上失效,调试会消耗性能。
8
- 2、将代码运行轨迹修改成可以点击的,点击对应行号可以跳转到代码位置。
9
- 3、提供一个猴子补丁,使用猴子补丁修改三方包的模块级全局变量MAX_VARIABLE_LENGTH ,最大变量默认是100,但对调试对接方json时候,往往很大,可以加大到最大显示10万个字母。
10
-
11
- """
12
- import datetime
13
- import os
14
- from functools import wraps
15
- import decorator
16
- import pysnooper # 需要安装 pip install pysnooper==0.0.11
17
- from pysnooper.pysnooper import get_write_function
18
- from pysnooper.tracer import Tracer, get_local_reprs, get_source_from_frame
19
-
20
- os_name = os.name
21
-
22
-
23
- class TracerCanClick(Tracer):
24
- """
25
- 使代码运行轨迹可点击。
26
- """
27
-
28
- def trace(self, frame, event, arg):
29
- if frame.f_code is not self.target_code_object:
30
- if self.depth == 1:
31
-
32
- return self.trace
33
- else:
34
- _frame_candidate = frame
35
- for i in range(1, self.depth):
36
- _frame_candidate = _frame_candidate.f_back
37
- if _frame_candidate is None:
38
- return self.trace
39
- elif _frame_candidate.f_code is self.target_code_object:
40
- indent = ' ' * 4 * i
41
- break
42
- else:
43
- return self.trace
44
- else:
45
- indent = ''
46
-
47
- self.frame_to_old_local_reprs[frame] = old_local_reprs = \
48
- self.frame_to_local_reprs[frame]
49
- self.frame_to_local_reprs[frame] = local_reprs = \
50
- get_local_reprs(frame, variables=self.variables)
51
-
52
- modified_local_reprs = {}
53
- newish_local_reprs = {}
54
-
55
- for key, value in local_reprs.items():
56
- if key not in old_local_reprs:
57
- newish_local_reprs[key] = value
58
- elif old_local_reprs[key] != value:
59
- modified_local_reprs[key] = value
60
-
61
- newish_string = ('Starting var:.. ' if event == 'call' else
62
- 'New var:....... ')
63
- for name, value_repr in newish_local_reprs.items():
64
- self.write('{indent}{newish_string}{name} = {value_repr}'.format(
65
- **locals()))
66
- for name, value_repr in modified_local_reprs.items():
67
- self.write('{indent}Modified var:.. {name} = {value_repr}'.format(
68
- **locals()))
69
-
70
- now_string = datetime.datetime.now().time().isoformat()
71
- source_line = get_source_from_frame(frame)[frame.f_lineno - 1]
72
- # print(frame)
73
- # print(dir(frame.f_code))
74
- # print(frame.f_code.co_filename)
75
- file_name_and_line = f'{frame.f_code.co_filename}:{frame.f_lineno}'
76
- # print(file_name_and_line)
77
-
78
- # self.write('{indent}{now_string} {event:9} '
79
- # '{frame.f_lineno:4} {source_line}'.format(**locals()))
80
- file_name_and_line2 = f'"{file_name_and_line}"'
81
- self.write('{indent}{now_string} {event:9} ' # REMIND 主要是修改了这一行,使debug可点击。
82
- '{file_name_and_line2:100} {source_line}'.format(**locals()))
83
- return self.trace
84
-
85
-
86
- def _snoop_can_click(output=None, variables=(), depth=1, prefix=''):
87
- write = get_write_function(output)
88
-
89
- # noinspection PyShadowingBuiltins
90
- @decorator.decorator
91
- def decorate(function, *args, **kwargs):
92
- target_code_object = function.__code__
93
- with TracerCanClick(target_code_object=target_code_object,
94
- write=write, variables=variables,
95
- depth=depth, prefix=prefix):
96
- return function(*args, **kwargs)
97
-
98
- return decorate
99
-
100
-
101
- def snoop_deco(output=None, variables: tuple = (), depth=1, prefix='', do_not_effect_on_linux=True, line_can_click=True):
102
- # REMIND 对装饰器再包装一次,不使用上面的和官方的。
103
- def _snoop(func):
104
- nonlocal prefix
105
- if prefix == '':
106
- prefix = f'调试 [{func.__name__}] 函数 --> '
107
-
108
- @wraps(func)
109
- def __snoop(*args, **kwargs):
110
- if os_name != 'nt' and do_not_effect_on_linux: # 不要修改任何代码,自动就会不在linux上debug,一般linux是部署机器。
111
- return func(*args, **kwargs)
112
- else:
113
- if line_can_click:
114
- return _snoop_can_click(output, variables, depth, prefix)(func)(*args, **kwargs)
115
- else:
116
- return pysnooper.snoop(output, variables, depth, prefix)(func)(*args, **kwargs)
117
-
118
- return __snoop
119
-
120
- return _snoop
121
-
122
-
123
- def patch_snooper_max_variable_length(max_lenth=100000):
124
- """
125
- 提供一个猴子补丁,三方包默认是变量最大显示100个字母,对于我这种经常debug对接方json的,要加到10万才能显示一个josn。
126
- 最好是放在name = main中去执行此补丁,否则由于模块是单例的永远只导入一次,会改变其他地方的运行表现。
127
- :param max_lenth:
128
- :return:
129
- """
130
- from pysnooper import tracer
131
- tracer.MAX_VARIABLE_LENGTH = max_lenth
132
-
133
-
134
- if __name__ == '__main__':
135
- patch_snooper_max_variable_length(10000)
136
-
137
-
138
- @snoop_deco(line_can_click=True, do_not_effect_on_linux=True)
139
- def fun2():
140
- x = 1
141
- x += 2
142
- y = '6' * 10
143
- if x == 3:
144
- print('ttttt')
145
- else:
146
- print('ffff')
147
-
148
-
149
- fun2()
@@ -1,32 +0,0 @@
1
- # Copyright 2019 Ram Rachum and collaborators.
2
- # This program is distributed under the MIT license.
3
- '''
4
-
5
- 基于最新的改版的pysnooper,修改成彩色可点击。
6
- PySnooper - Never use print for debugging again
7
-
8
- Usage:
9
-
10
- import pysnooper
11
-
12
- @pysnooper.snoop()
13
- def your_function(x):
14
- ...
15
-
16
- A log will be written to stderr showing the lines executed and variables
17
- changed in the decorated function.
18
-
19
- For more information, see https://github.com/cool-RR/PySnooper
20
- '''
21
-
22
- from .tracer import Tracer as snoop
23
- from .variables import Attrs, Exploding, Indices, Keys
24
- import collections
25
-
26
- __VersionInfo = collections.namedtuple('VersionInfo',
27
- ('major', 'minor', 'micro'))
28
-
29
- __version__ = '0.2.8'
30
- __version_info__ = __VersionInfo(*(map(int, __version__.split('.'))))
31
-
32
- del collections, __VersionInfo # Avoid polluting the namespace
@@ -1,82 +0,0 @@
1
- # Copyright 2019 Ram Rachum and collaborators.
2
- # This program is distributed under the MIT license.
3
- '''Python 2/3 compatibility'''
4
-
5
- import abc
6
- import os
7
- import inspect
8
- import sys
9
- import datetime as datetime_module
10
-
11
- PY3 = (sys.version_info[0] == 3)
12
- PY2 = not PY3
13
-
14
- if hasattr(abc, 'ABC'):
15
- ABC = abc.ABC
16
- else:
17
- class ABC(object):
18
- """Helper class that provides a standard way to create an ABC using
19
- inheritance.
20
- """
21
- __metaclass__ = abc.ABCMeta
22
- __slots__ = ()
23
-
24
-
25
- if hasattr(os, 'PathLike'):
26
- PathLike = os.PathLike
27
- else:
28
- class PathLike(ABC):
29
- """Abstract base class for implementing the file system path protocol."""
30
-
31
- @abc.abstractmethod
32
- def __fspath__(self):
33
- """Return the file system path representation of the object."""
34
- raise NotImplementedError
35
-
36
- @classmethod
37
- def __subclasshook__(cls, subclass):
38
- return (
39
- hasattr(subclass, '__fspath__') or
40
- # Make a concession for older `pathlib` versions:g
41
- (hasattr(subclass, 'open') and
42
- 'path' in subclass.__name__.lower())
43
- )
44
-
45
-
46
- try:
47
- iscoroutinefunction = inspect.iscoroutinefunction
48
- except AttributeError:
49
- iscoroutinefunction = lambda whatever: False # Lolz
50
-
51
- try:
52
- isasyncgenfunction = inspect.isasyncgenfunction
53
- except AttributeError:
54
- isasyncgenfunction = lambda whatever: False # Lolz
55
-
56
-
57
- if PY3:
58
- string_types = (str,)
59
- text_type = str
60
- else:
61
- string_types = (basestring,)
62
- text_type = unicode
63
-
64
- try:
65
- from collections import abc as collections_abc
66
- except ImportError: # Python 2.7
67
- import collections as collections_abc
68
-
69
- if sys.version_info[:2] >= (3, 6):
70
- time_isoformat = datetime_module.time.isoformat
71
- else:
72
- def time_isoformat(time, timespec='microseconds'):
73
- assert isinstance(time, datetime_module.time)
74
- if timespec != 'microseconds':
75
- raise NotImplementedError
76
- result = '{:02d}:{:02d}:{:02d}.{:06d}'.format(
77
- time.hour, time.minute, time.second, time.microsecond
78
- )
79
- assert len(result) == 15
80
- return result
81
-
82
-