funboost 44.8__py3-none-any.whl → 44.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 (78) hide show
  1. funboost/__init__.py +1 -1
  2. funboost/constant.py +14 -4
  3. funboost/consumers/base_consumer.py +48 -20
  4. funboost/core/booster.py +15 -0
  5. funboost/core/current_task.py +87 -68
  6. funboost/core/func_params_model.py +8 -0
  7. funboost/function_result_web/__pycache__/functions.cpython-39.pyc +0 -0
  8. funboost/publishers/base_publisher.py +21 -2
  9. funboost/set_frame_config.py +2 -1
  10. funboost/utils/class_utils.py +101 -51
  11. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-39.pyc +0 -0
  12. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-39.pyc +0 -0
  13. funboost/utils/dependency_packages_in_pythonpath/aioredis/__init__.py +59 -59
  14. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-39.pyc +0 -0
  15. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-39.pyc +0 -0
  16. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-39.pyc +0 -0
  17. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-39.pyc +0 -0
  18. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-39.pyc +0 -0
  19. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-39.pyc +0 -0
  20. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-39.pyc +0 -0
  21. funboost/utils/dependency_packages_in_pythonpath/aioredis/client.py +4804 -4804
  22. funboost/utils/dependency_packages_in_pythonpath/aioredis/compat.py +8 -8
  23. funboost/utils/dependency_packages_in_pythonpath/aioredis/connection.py +1668 -1668
  24. funboost/utils/dependency_packages_in_pythonpath/aioredis/exceptions.py +96 -96
  25. funboost/utils/dependency_packages_in_pythonpath/aioredis/lock.py +306 -306
  26. funboost/utils/dependency_packages_in_pythonpath/aioredis/log.py +15 -15
  27. funboost/utils/dependency_packages_in_pythonpath/aioredis/sentinel.py +329 -329
  28. funboost/utils/dependency_packages_in_pythonpath/aioredis/utils.py +61 -61
  29. funboost/utils/dependency_packages_in_pythonpath/func_timeout/StoppableThread.py +134 -133
  30. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__init__.py +16 -16
  31. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-39.pyc +0 -0
  32. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-39.pyc +0 -0
  33. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-39.pyc +0 -0
  34. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-39.pyc +0 -0
  35. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-39.pyc +0 -0
  36. funboost/utils/dependency_packages_in_pythonpath/func_timeout/dafunc.py +244 -244
  37. funboost/utils/dependency_packages_in_pythonpath/func_timeout/dafunc2222.py +244 -0
  38. funboost/utils/dependency_packages_in_pythonpath/func_timeout/exceptions.py +98 -98
  39. funboost/utils/dependency_packages_in_pythonpath/func_timeout/py2_raise.py +7 -7
  40. funboost/utils/dependency_packages_in_pythonpath/func_timeout/py3_raise.py +7 -7
  41. funboost/utils/times/__init__.py +85 -85
  42. funboost/utils/times/version.py +1 -1
  43. {funboost-44.8.dist-info → funboost-44.9.dist-info}/METADATA +1 -2
  44. {funboost-44.8.dist-info → funboost-44.9.dist-info}/RECORD +48 -76
  45. {funboost-44.8.dist-info → funboost-44.9.dist-info}/entry_points.txt +0 -1
  46. funboost/function_result_web/__pycache__/app.cpython-37.pyc +0 -0
  47. funboost/function_result_web/__pycache__/functions.cpython-37.pyc +0 -0
  48. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-311.pyc +0 -0
  49. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-37.pyc +0 -0
  50. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-311.pyc +0 -0
  51. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-37.pyc +0 -0
  52. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-311.pyc +0 -0
  53. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-37.pyc +0 -0
  54. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-311.pyc +0 -0
  55. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-37.pyc +0 -0
  56. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-311.pyc +0 -0
  57. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-37.pyc +0 -0
  58. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-311.pyc +0 -0
  59. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-37.pyc +0 -0
  60. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-311.pyc +0 -0
  61. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-37.pyc +0 -0
  62. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-311.pyc +0 -0
  63. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-37.pyc +0 -0
  64. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-311.pyc +0 -0
  65. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-37.pyc +0 -0
  66. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-311.pyc +0 -0
  67. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-37.pyc +0 -0
  68. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-311.pyc +0 -0
  69. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-37.pyc +0 -0
  70. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-311.pyc +0 -0
  71. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-37.pyc +0 -0
  72. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-311.pyc +0 -0
  73. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-37.pyc +0 -0
  74. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-311.pyc +0 -0
  75. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-37.pyc +0 -0
  76. {funboost-44.8.dist-info → funboost-44.9.dist-info}/LICENSE +0 -0
  77. {funboost-44.8.dist-info → funboost-44.9.dist-info}/WHEEL +0 -0
  78. {funboost-44.8.dist-info → funboost-44.9.dist-info}/top_level.txt +0 -0
@@ -1,61 +1,61 @@
1
- from typing import TYPE_CHECKING, TypeVar, overload
2
-
3
- if TYPE_CHECKING:
4
- from aioredis import Redis
5
- from aioredis.client import Pipeline
6
-
7
-
8
- try:
9
- import hiredis # noqa
10
-
11
- HIREDIS_AVAILABLE = True
12
- except ImportError:
13
- HIREDIS_AVAILABLE = False
14
-
15
-
16
- _T = TypeVar("_T")
17
-
18
-
19
- def from_url(url, **kwargs):
20
- """
21
- Returns an active Redis client generated from the given database URL.
22
-
23
- Will attempt to extract the database id from the path url fragment, if
24
- none is provided.
25
- """
26
- from aioredis.client import Redis
27
-
28
- return Redis.from_url(url, **kwargs)
29
-
30
-
31
- class pipeline:
32
- def __init__(self, redis_obj: "Redis"):
33
- self.p: "Pipeline" = redis_obj.pipeline()
34
-
35
- async def __aenter__(self) -> "Pipeline":
36
- return self.p
37
-
38
- async def __aexit__(self, exc_type, exc_val, exc_tb):
39
- await self.p.execute()
40
- del self.p
41
-
42
-
43
- # Mypy bug: https://github.com/python/mypy/issues/11005
44
- @overload
45
- def str_if_bytes(value: bytes) -> str: # type: ignore[misc]
46
- ...
47
-
48
-
49
- @overload
50
- def str_if_bytes(value: _T) -> _T:
51
- ...
52
-
53
-
54
- def str_if_bytes(value: object) -> object:
55
- return (
56
- value.decode("utf-8", errors="replace") if isinstance(value, bytes) else value
57
- )
58
-
59
-
60
- def safe_str(value: object) -> str:
61
- return str(str_if_bytes(value))
1
+ from typing import TYPE_CHECKING, TypeVar, overload
2
+
3
+ if TYPE_CHECKING:
4
+ from aioredis import Redis
5
+ from aioredis.client import Pipeline
6
+
7
+
8
+ try:
9
+ import hiredis # noqa
10
+
11
+ HIREDIS_AVAILABLE = True
12
+ except ImportError:
13
+ HIREDIS_AVAILABLE = False
14
+
15
+
16
+ _T = TypeVar("_T")
17
+
18
+
19
+ def from_url(url, **kwargs):
20
+ """
21
+ Returns an active Redis client generated from the given database URL.
22
+
23
+ Will attempt to extract the database id from the path url fragment, if
24
+ none is provided.
25
+ """
26
+ from aioredis.client import Redis
27
+
28
+ return Redis.from_url(url, **kwargs)
29
+
30
+
31
+ class pipeline:
32
+ def __init__(self, redis_obj: "Redis"):
33
+ self.p: "Pipeline" = redis_obj.pipeline()
34
+
35
+ async def __aenter__(self) -> "Pipeline":
36
+ return self.p
37
+
38
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
39
+ await self.p.execute()
40
+ del self.p
41
+
42
+
43
+ # Mypy bug: https://github.com/python/mypy/issues/11005
44
+ @overload
45
+ def str_if_bytes(value: bytes) -> str: # type: ignore[misc]
46
+ ...
47
+
48
+
49
+ @overload
50
+ def str_if_bytes(value: _T) -> _T:
51
+ ...
52
+
53
+
54
+ def str_if_bytes(value: object) -> object:
55
+ return (
56
+ value.decode("utf-8", errors="replace") if isinstance(value, bytes) else value
57
+ )
58
+
59
+
60
+ def safe_str(value: object) -> str:
61
+ return str(str_if_bytes(value))
@@ -1,133 +1,134 @@
1
- '''
2
- Copyright (c) 2016, 2017, 2019 Timothy Savannah All Rights Reserved.
3
-
4
- Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as
5
- LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE
6
- '''
7
-
8
- import os
9
- import ctypes
10
- import threading
11
-
12
- __all__ = ('StoppableThread', 'JoinThread')
13
-
14
- class StoppableThread(threading.Thread):
15
- '''
16
- StoppableThread - A thread that can be stopped by forcing an exception in the execution context.
17
-
18
- This works both to interrupt code that is in C or in python code, at either the next call to a python function,
19
- or the next line in python code.
20
-
21
- It is recommended that if you call stop ( @see StoppableThread.stop ) that you use an exception that inherits BaseException, to ensure it likely isn't caught.
22
-
23
- Also, beware unmarked exception handlers in your code. Code like this:
24
-
25
- while True:
26
- try:
27
- doSomething()
28
- except:
29
- continue
30
-
31
- will never be able to abort, because the exception you raise is immediately caught.
32
-
33
- The exception is raised over and over, with a specifed delay (default 2.0 seconds)
34
- '''
35
-
36
-
37
- def _stopThread(self, exception, raiseEvery=2.0):
38
- '''
39
- _stopThread - @see StoppableThread.stop
40
- '''
41
- if self.is_alive() is False:
42
- return True
43
-
44
- self._stderr = open(os.devnull, 'w')
45
-
46
- # Create "joining" thread which will raise the provided exception
47
- # on a repeat, until the thread stops.
48
- joinThread = JoinThread(self, exception, repeatEvery=raiseEvery)
49
-
50
- # Try to prevent spurrious prints
51
- joinThread._stderr = self._stderr
52
- joinThread.start()
53
- joinThread._stderr = self._stderr
54
-
55
-
56
- def stop(self, exception, raiseEvery=2.0):
57
- '''
58
- Stops the thread by raising a given exception.
59
-
60
- @param exception <Exception type> - Exception to throw. Likely, you want to use something
61
-
62
- that inherits from BaseException (so except BaseException as e: continue; isn't a problem)
63
-
64
- This should be a class/type, NOT an instance, i.e. MyExceptionType not MyExceptionType()
65
-
66
-
67
- @param raiseEvery <float> Default 2.0 - We will keep raising this exception every #raiseEvery seconds,
68
-
69
- until the thread terminates.
70
-
71
- If your code traps a specific exception type, this will allow you #raiseEvery seconds to cleanup before exit.
72
-
73
- If you're calling third-party code you can't control, which catches BaseException, set this to a low number
74
-
75
- to break out of their exception handler.
76
-
77
-
78
- @return <None>
79
- '''
80
- return self._stopThread(exception, raiseEvery)
81
-
82
-
83
- class JoinThread(threading.Thread):
84
- '''
85
- JoinThread - The workhouse that stops the StoppableThread.
86
-
87
- Takes an exception, and upon being started immediately raises that exception in the current context
88
- of the thread's execution (so next line of python gets it, or next call to a python api function in C code ).
89
-
90
- @see StoppableThread for more details
91
- '''
92
-
93
- def __init__(self, otherThread, exception, repeatEvery=2.0):
94
- '''
95
- __init__ - Create a JoinThread (don't forget to call .start() ! )
96
-
97
- @param otherThread <threading.Thread> - A thread
98
-
99
- @param exception <BaseException> - An exception. Should be a BaseException, to prevent "catch Exception as e: continue" type code
100
- from never being terminated. If such code is unavoidable, you can try setting #repeatEvery to a very low number, like .00001,
101
- and it will hopefully raise within the context of the catch, and be able to break free.
102
-
103
- @param repeatEvery <float> Default 2.0 - After starting, the given exception is immediately raised. Then, every #repeatEvery seconds,
104
- it is raised again, until the thread terminates.
105
- '''
106
- threading.Thread.__init__(self)
107
- self.otherThread = otherThread
108
- self.exception = exception
109
- self.repeatEvery = repeatEvery
110
- self.daemon = True
111
-
112
- def run(self):
113
- '''
114
- run - The thread main. Will attempt to stop and join the attached thread.
115
- '''
116
-
117
- # Try to silence default exception printing.
118
- self.otherThread._Thread__stderr = self._stderr
119
- if hasattr(self.otherThread, '_Thread__stop'):
120
- # If py2, call this first to start thread termination cleanly.
121
- # Python3 does not need such ( nor does it provide.. )
122
- self.otherThread._Thread__stop()
123
- while self.otherThread.is_alive():
124
- # We loop raising exception incase it's caught hopefully this breaks us far out.
125
- ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.otherThread.ident), ctypes.py_object(self.exception))
126
- self.otherThread.join(self.repeatEvery)
127
-
128
- try:
129
- self._stderr.close()
130
- except:
131
- pass
132
-
133
- # vim: set ts=4 sw=4 expandtab :
1
+ '''
2
+ Copyright (c) 2016, 2017, 2019 Timothy Savannah All Rights Reserved.
3
+
4
+ Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as
5
+ LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE
6
+ '''
7
+
8
+ import os
9
+ import ctypes
10
+ import threading
11
+
12
+ from funboost.core.current_task import FctContextThread
13
+ __all__ = ('StoppableThread', 'JoinThread')
14
+
15
+ class StoppableThread(FctContextThread): # 这里重要,继承的是FctContextThread,而不是原生 threading.Thread
16
+ '''
17
+ StoppableThread - A thread that can be stopped by forcing an exception in the execution context.
18
+
19
+ This works both to interrupt code that is in C or in python code, at either the next call to a python function,
20
+ or the next line in python code.
21
+
22
+ It is recommended that if you call stop ( @see StoppableThread.stop ) that you use an exception that inherits BaseException, to ensure it likely isn't caught.
23
+
24
+ Also, beware unmarked exception handlers in your code. Code like this:
25
+
26
+ while True:
27
+ try:
28
+ doSomething()
29
+ except:
30
+ continue
31
+
32
+ will never be able to abort, because the exception you raise is immediately caught.
33
+
34
+ The exception is raised over and over, with a specifed delay (default 2.0 seconds)
35
+ '''
36
+
37
+
38
+ def _stopThread(self, exception, raiseEvery=2.0):
39
+ '''
40
+ _stopThread - @see StoppableThread.stop
41
+ '''
42
+ if self.is_alive() is False:
43
+ return True
44
+
45
+ self._stderr = open(os.devnull, 'w')
46
+
47
+ # Create "joining" thread which will raise the provided exception
48
+ # on a repeat, until the thread stops.
49
+ joinThread = JoinThread(self, exception, repeatEvery=raiseEvery)
50
+
51
+ # Try to prevent spurrious prints
52
+ joinThread._stderr = self._stderr
53
+ joinThread.start()
54
+ joinThread._stderr = self._stderr
55
+
56
+
57
+ def stop(self, exception, raiseEvery=2.0):
58
+ '''
59
+ Stops the thread by raising a given exception.
60
+
61
+ @param exception <Exception type> - Exception to throw. Likely, you want to use something
62
+
63
+ that inherits from BaseException (so except BaseException as e: continue; isn't a problem)
64
+
65
+ This should be a class/type, NOT an instance, i.e. MyExceptionType not MyExceptionType()
66
+
67
+
68
+ @param raiseEvery <float> Default 2.0 - We will keep raising this exception every #raiseEvery seconds,
69
+
70
+ until the thread terminates.
71
+
72
+ If your code traps a specific exception type, this will allow you #raiseEvery seconds to cleanup before exit.
73
+
74
+ If you're calling third-party code you can't control, which catches BaseException, set this to a low number
75
+
76
+ to break out of their exception handler.
77
+
78
+
79
+ @return <None>
80
+ '''
81
+ return self._stopThread(exception, raiseEvery)
82
+
83
+
84
+ class JoinThread(FctContextThread):
85
+ '''
86
+ JoinThread - The workhouse that stops the StoppableThread.
87
+
88
+ Takes an exception, and upon being started immediately raises that exception in the current context
89
+ of the thread's execution (so next line of python gets it, or next call to a python api function in C code ).
90
+
91
+ @see StoppableThread for more details
92
+ '''
93
+
94
+ def __init__(self, otherThread, exception, repeatEvery=2.0):
95
+ '''
96
+ __init__ - Create a JoinThread (don't forget to call .start() ! )
97
+
98
+ @param otherThread <threading.Thread> - A thread
99
+
100
+ @param exception <BaseException> - An exception. Should be a BaseException, to prevent "catch Exception as e: continue" type code
101
+ from never being terminated. If such code is unavoidable, you can try setting #repeatEvery to a very low number, like .00001,
102
+ and it will hopefully raise within the context of the catch, and be able to break free.
103
+
104
+ @param repeatEvery <float> Default 2.0 - After starting, the given exception is immediately raised. Then, every #repeatEvery seconds,
105
+ it is raised again, until the thread terminates.
106
+ '''
107
+ threading.Thread.__init__(self)
108
+ self.otherThread = otherThread
109
+ self.exception = exception
110
+ self.repeatEvery = repeatEvery
111
+ self.daemon = True
112
+
113
+ def run(self):
114
+ '''
115
+ run - The thread main. Will attempt to stop and join the attached thread.
116
+ '''
117
+
118
+ # Try to silence default exception printing.
119
+ self.otherThread._Thread__stderr = self._stderr
120
+ if hasattr(self.otherThread, '_Thread__stop'):
121
+ # If py2, call this first to start thread termination cleanly.
122
+ # Python3 does not need such ( nor does it provide.. )
123
+ self.otherThread._Thread__stop()
124
+ while self.otherThread.is_alive():
125
+ # We loop raising exception incase it's caught hopefully this breaks us far out.
126
+ ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.otherThread.ident), ctypes.py_object(self.exception))
127
+ self.otherThread.join(self.repeatEvery)
128
+
129
+ try:
130
+ self._stderr.close()
131
+ except:
132
+ pass
133
+
134
+ # vim: set ts=4 sw=4 expandtab :
@@ -1,16 +1,16 @@
1
- '''
2
- Copyright (c) 2016, 2017, 2019 Tim Savannah All Rights Reserved.
3
-
4
- Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as
5
- LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE
6
- '''
7
-
8
-
9
- __version__ = '4.3.5'
10
- __version_tuple__ = (4, 3, 5)
11
-
12
- __all__ = ('func_timeout', 'func_set_timeout', 'FunctionTimedOut', 'StoppableThread')
13
-
14
- from .exceptions import FunctionTimedOut
15
- from .dafunc import func_timeout, func_set_timeout
16
- from .StoppableThread import StoppableThread
1
+ '''
2
+ Copyright (c) 2016, 2017, 2019 Tim Savannah All Rights Reserved.
3
+
4
+ Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as
5
+ LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE
6
+ '''
7
+
8
+
9
+ __version__ = '4.3.5'
10
+ __version_tuple__ = (4, 3, 5)
11
+
12
+ __all__ = ('func_timeout', 'func_set_timeout', 'FunctionTimedOut', 'StoppableThread')
13
+
14
+ from .exceptions import FunctionTimedOut
15
+ from .dafunc import func_timeout, func_set_timeout
16
+ from .StoppableThread import StoppableThread