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.
- funboost/__init__.py +1 -1
- funboost/consumers/base_consumer.py +9 -3
- funboost/consumers/local_python_queue_consumer.py +2 -2
- funboost/core/current_task.py +1 -1
- funboost/core/func_params_model.py +2 -4
- funboost/function_result_web/__pycache__/functions.cpython-39.pyc +0 -0
- funboost/publishers/base_publisher.py +3 -0
- funboost/publishers/local_python_queue_publisher.py +8 -7
- funboost/queues/memory_queues_map.py +11 -0
- funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__init__.py +59 -59
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/client.py +4804 -4804
- funboost/utils/dependency_packages_in_pythonpath/aioredis/compat.py +8 -8
- funboost/utils/dependency_packages_in_pythonpath/aioredis/connection.py +1668 -1668
- funboost/utils/dependency_packages_in_pythonpath/aioredis/exceptions.py +96 -96
- funboost/utils/dependency_packages_in_pythonpath/aioredis/lock.py +306 -306
- funboost/utils/dependency_packages_in_pythonpath/aioredis/log.py +15 -15
- funboost/utils/dependency_packages_in_pythonpath/aioredis/sentinel.py +329 -329
- funboost/utils/dependency_packages_in_pythonpath/aioredis/utils.py +61 -61
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__init__.py +16 -16
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-39.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/exceptions.py +98 -98
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/py2_raise.py +7 -7
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/py3_raise.py +7 -7
- funboost/utils/times/__init__.py +85 -85
- funboost/utils/times/version.py +1 -1
- {funboost-45.4.dist-info → funboost-45.7.dist-info}/METADATA +20 -10
- {funboost-45.4.dist-info → funboost-45.7.dist-info}/RECORD +44 -72
- {funboost-45.4.dist-info → funboost-45.7.dist-info}/entry_points.txt +0 -1
- funboost/function_result_web/__pycache__/app.cpython-37.pyc +0 -0
- funboost/function_result_web/__pycache__/functions.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-37.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-311.pyc +0 -0
- funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-37.pyc +0 -0
- {funboost-45.4.dist-info → funboost-45.7.dist-info}/LICENSE +0 -0
- {funboost-45.4.dist-info → funboost-45.7.dist-info}/WHEEL +0 -0
- {funboost-45.4.dist-info → funboost-45.7.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,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
|
|
Binary file
|
funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-39.pyc
CHANGED
|
Binary file
|
funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-39.pyc
CHANGED
|
Binary file
|
funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-39.pyc
CHANGED
|
Binary file
|
funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-39.pyc
CHANGED
|
Binary file
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Copyright (c) 2016 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
|
-
__all__ = ('FunctionTimedOut', 'RETRY_SAME_TIMEOUT')
|
|
9
|
-
|
|
10
|
-
RETRY_SAME_TIMEOUT = 'RETRY_SAME_TIMEOUT'
|
|
11
|
-
|
|
12
|
-
class FunctionTimedOut(BaseException):
|
|
13
|
-
'''
|
|
14
|
-
FunctionTimedOut - Exception raised when a function times out
|
|
15
|
-
|
|
16
|
-
@property timedOutAfter - Number of seconds before timeout was triggered
|
|
17
|
-
|
|
18
|
-
@property timedOutFunction - Function called which timed out
|
|
19
|
-
@property timedOutArgs - Ordered args to function
|
|
20
|
-
@property timedOutKwargs - Keyword args to function
|
|
21
|
-
|
|
22
|
-
@method retry - Retries the function with same arguments, with option to run with original timeout, no timeout, or a different
|
|
23
|
-
explicit timeout. @see FunctionTimedOut.retry
|
|
24
|
-
'''
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def __init__(self, msg='', timedOutAfter=None, timedOutFunction=None, timedOutArgs=None, timedOutKwargs=None):
|
|
28
|
-
'''
|
|
29
|
-
__init__ - Create this exception type.
|
|
30
|
-
|
|
31
|
-
You should not need to do this outside of testing, it will be created by the func_timeout API
|
|
32
|
-
|
|
33
|
-
@param msg <str> - A predefined message, otherwise we will attempt to generate one from the other arguments.
|
|
34
|
-
|
|
35
|
-
@param timedOutAfter <None/float> - Number of seconds before timing-out. Filled-in by API, None will produce "Unknown"
|
|
36
|
-
|
|
37
|
-
@param timedOutFunction <None/function> - Reference to the function that timed-out. Filled-in by API." None will produce "Unknown Function"
|
|
38
|
-
|
|
39
|
-
@param timedOutArgs <None/tuple/list> - List of fixed-order arguments ( *args ), or None for no args.
|
|
40
|
-
|
|
41
|
-
@param timedOutKwargs <None/dict> - Dict of keyword arg ( **kwargs ) names to values, or None for no kwargs.
|
|
42
|
-
|
|
43
|
-
'''
|
|
44
|
-
|
|
45
|
-
self.timedOutAfter = timedOutAfter
|
|
46
|
-
|
|
47
|
-
self.timedOutFunction = timedOutFunction
|
|
48
|
-
self.timedOutArgs = timedOutArgs
|
|
49
|
-
self.timedOutKwargs = timedOutKwargs
|
|
50
|
-
|
|
51
|
-
if not msg:
|
|
52
|
-
msg = self.getMsg()
|
|
53
|
-
|
|
54
|
-
BaseException.__init__(self, msg)
|
|
55
|
-
|
|
56
|
-
self.msg = msg
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def getMsg(self):
|
|
60
|
-
'''
|
|
61
|
-
getMsg - Generate a default message based on parameters to FunctionTimedOut exception'
|
|
62
|
-
|
|
63
|
-
@return <str> - Message
|
|
64
|
-
'''
|
|
65
|
-
# Try to gather the function name, if available.
|
|
66
|
-
# If it is not, default to an "unknown" string to allow default instantiation
|
|
67
|
-
if self.timedOutFunction is not None:
|
|
68
|
-
timedOutFuncName = self.timedOutFunction.__name__
|
|
69
|
-
else:
|
|
70
|
-
timedOutFuncName = 'Unknown Function'
|
|
71
|
-
if self.timedOutAfter is not None:
|
|
72
|
-
timedOutAfterStr = "%f" %(self.timedOutAfter, )
|
|
73
|
-
else:
|
|
74
|
-
timedOutAfterStr = "Unknown"
|
|
75
|
-
|
|
76
|
-
return 'Function %s (args=%s) (kwargs=%s) timed out after %s seconds.\n' %(timedOutFuncName, repr(self.timedOutArgs), repr(self.timedOutKwargs), timedOutAfterStr)
|
|
77
|
-
|
|
78
|
-
def retry(self, timeout=RETRY_SAME_TIMEOUT):
|
|
79
|
-
'''
|
|
80
|
-
retry - Retry the timed-out function with same arguments.
|
|
81
|
-
|
|
82
|
-
@param timeout <float/RETRY_SAME_TIMEOUT/None> Default RETRY_SAME_TIMEOUT
|
|
83
|
-
|
|
84
|
-
If RETRY_SAME_TIMEOUT : Will retry the function same args, same timeout
|
|
85
|
-
If a float/int : Will retry the function same args with provided timeout
|
|
86
|
-
If None : Will retry function same args no timeout
|
|
87
|
-
|
|
88
|
-
@return - Returnval from function
|
|
89
|
-
'''
|
|
90
|
-
if timeout is None:
|
|
91
|
-
return self.timedOutFunction(*(self.timedOutArgs), **self.timedOutKwargs)
|
|
92
|
-
|
|
93
|
-
from .dafunc import func_timeout
|
|
94
|
-
|
|
95
|
-
if timeout == RETRY_SAME_TIMEOUT:
|
|
96
|
-
timeout = self.timedOutAfter
|
|
97
|
-
|
|
98
|
-
return func_timeout(timeout, self.timedOutFunction, args=self.timedOutArgs, kwargs=self.timedOutKwargs)
|
|
1
|
+
'''
|
|
2
|
+
Copyright (c) 2016 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
|
+
__all__ = ('FunctionTimedOut', 'RETRY_SAME_TIMEOUT')
|
|
9
|
+
|
|
10
|
+
RETRY_SAME_TIMEOUT = 'RETRY_SAME_TIMEOUT'
|
|
11
|
+
|
|
12
|
+
class FunctionTimedOut(BaseException):
|
|
13
|
+
'''
|
|
14
|
+
FunctionTimedOut - Exception raised when a function times out
|
|
15
|
+
|
|
16
|
+
@property timedOutAfter - Number of seconds before timeout was triggered
|
|
17
|
+
|
|
18
|
+
@property timedOutFunction - Function called which timed out
|
|
19
|
+
@property timedOutArgs - Ordered args to function
|
|
20
|
+
@property timedOutKwargs - Keyword args to function
|
|
21
|
+
|
|
22
|
+
@method retry - Retries the function with same arguments, with option to run with original timeout, no timeout, or a different
|
|
23
|
+
explicit timeout. @see FunctionTimedOut.retry
|
|
24
|
+
'''
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def __init__(self, msg='', timedOutAfter=None, timedOutFunction=None, timedOutArgs=None, timedOutKwargs=None):
|
|
28
|
+
'''
|
|
29
|
+
__init__ - Create this exception type.
|
|
30
|
+
|
|
31
|
+
You should not need to do this outside of testing, it will be created by the func_timeout API
|
|
32
|
+
|
|
33
|
+
@param msg <str> - A predefined message, otherwise we will attempt to generate one from the other arguments.
|
|
34
|
+
|
|
35
|
+
@param timedOutAfter <None/float> - Number of seconds before timing-out. Filled-in by API, None will produce "Unknown"
|
|
36
|
+
|
|
37
|
+
@param timedOutFunction <None/function> - Reference to the function that timed-out. Filled-in by API." None will produce "Unknown Function"
|
|
38
|
+
|
|
39
|
+
@param timedOutArgs <None/tuple/list> - List of fixed-order arguments ( *args ), or None for no args.
|
|
40
|
+
|
|
41
|
+
@param timedOutKwargs <None/dict> - Dict of keyword arg ( **kwargs ) names to values, or None for no kwargs.
|
|
42
|
+
|
|
43
|
+
'''
|
|
44
|
+
|
|
45
|
+
self.timedOutAfter = timedOutAfter
|
|
46
|
+
|
|
47
|
+
self.timedOutFunction = timedOutFunction
|
|
48
|
+
self.timedOutArgs = timedOutArgs
|
|
49
|
+
self.timedOutKwargs = timedOutKwargs
|
|
50
|
+
|
|
51
|
+
if not msg:
|
|
52
|
+
msg = self.getMsg()
|
|
53
|
+
|
|
54
|
+
BaseException.__init__(self, msg)
|
|
55
|
+
|
|
56
|
+
self.msg = msg
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def getMsg(self):
|
|
60
|
+
'''
|
|
61
|
+
getMsg - Generate a default message based on parameters to FunctionTimedOut exception'
|
|
62
|
+
|
|
63
|
+
@return <str> - Message
|
|
64
|
+
'''
|
|
65
|
+
# Try to gather the function name, if available.
|
|
66
|
+
# If it is not, default to an "unknown" string to allow default instantiation
|
|
67
|
+
if self.timedOutFunction is not None:
|
|
68
|
+
timedOutFuncName = self.timedOutFunction.__name__
|
|
69
|
+
else:
|
|
70
|
+
timedOutFuncName = 'Unknown Function'
|
|
71
|
+
if self.timedOutAfter is not None:
|
|
72
|
+
timedOutAfterStr = "%f" %(self.timedOutAfter, )
|
|
73
|
+
else:
|
|
74
|
+
timedOutAfterStr = "Unknown"
|
|
75
|
+
|
|
76
|
+
return 'Function %s (args=%s) (kwargs=%s) timed out after %s seconds.\n' %(timedOutFuncName, repr(self.timedOutArgs), repr(self.timedOutKwargs), timedOutAfterStr)
|
|
77
|
+
|
|
78
|
+
def retry(self, timeout=RETRY_SAME_TIMEOUT):
|
|
79
|
+
'''
|
|
80
|
+
retry - Retry the timed-out function with same arguments.
|
|
81
|
+
|
|
82
|
+
@param timeout <float/RETRY_SAME_TIMEOUT/None> Default RETRY_SAME_TIMEOUT
|
|
83
|
+
|
|
84
|
+
If RETRY_SAME_TIMEOUT : Will retry the function same args, same timeout
|
|
85
|
+
If a float/int : Will retry the function same args with provided timeout
|
|
86
|
+
If None : Will retry function same args no timeout
|
|
87
|
+
|
|
88
|
+
@return - Returnval from function
|
|
89
|
+
'''
|
|
90
|
+
if timeout is None:
|
|
91
|
+
return self.timedOutFunction(*(self.timedOutArgs), **self.timedOutKwargs)
|
|
92
|
+
|
|
93
|
+
from .dafunc import func_timeout
|
|
94
|
+
|
|
95
|
+
if timeout == RETRY_SAME_TIMEOUT:
|
|
96
|
+
timeout = self.timedOutAfter
|
|
97
|
+
|
|
98
|
+
return func_timeout(timeout, self.timedOutFunction, args=self.timedOutArgs, kwargs=self.timedOutKwargs)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# Python2 allows specifying an alternate traceback.
|
|
4
|
-
def raise_exception(exception):
|
|
5
|
-
'''
|
|
6
|
-
raise exception[0] , None , exception[0].__traceback__ # noqa
|
|
7
|
-
'''
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# Python2 allows specifying an alternate traceback.
|
|
4
|
+
def raise_exception(exception):
|
|
5
|
+
'''
|
|
6
|
+
raise exception[0] , None , exception[0].__traceback__ # noqa
|
|
7
|
+
'''
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
# PEP 409 - Raise with the chained exception context disabled
|
|
3
|
-
# This, in effect, prevents the "funcwrap" wrapper ( chained
|
|
4
|
-
# in context to an exception raised here, due to scope )
|
|
5
|
-
# Only available in python3.3+
|
|
6
|
-
def raise_exception(exception):
|
|
7
|
-
raise exception[0] from None
|
|
1
|
+
|
|
2
|
+
# PEP 409 - Raise with the chained exception context disabled
|
|
3
|
+
# This, in effect, prevents the "funcwrap" wrapper ( chained
|
|
4
|
+
# in context to an exception raised here, due to scope )
|
|
5
|
+
# Only available in python3.3+
|
|
6
|
+
def raise_exception(exception):
|
|
7
|
+
raise exception[0] from None
|
funboost/utils/times/__init__.py
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
import arrow
|
|
5
|
-
|
|
6
|
-
from .version import VERSION
|
|
7
|
-
|
|
8
|
-
PY3 = sys.version_info[0] == 3
|
|
9
|
-
if PY3:
|
|
10
|
-
string_types = str
|
|
11
|
-
else:
|
|
12
|
-
string_types = basestring
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__author__ = 'Vincent Driessen <vincent@3rdcloud.com>'
|
|
16
|
-
__version__ = VERSION
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def to_universal(local_dt, timezone=None):
|
|
20
|
-
"""
|
|
21
|
-
Converts the given local datetime or UNIX timestamp to a universal
|
|
22
|
-
datetime.
|
|
23
|
-
"""
|
|
24
|
-
if isinstance(local_dt, (int, float)):
|
|
25
|
-
if timezone is not None:
|
|
26
|
-
raise ValueError('Timezone argument illegal when using UNIX timestamps.')
|
|
27
|
-
return from_unix(local_dt)
|
|
28
|
-
elif isinstance(local_dt, string_types):
|
|
29
|
-
local_dt = arrow.get(local_dt).to('UTC').naive
|
|
30
|
-
|
|
31
|
-
return from_local(local_dt, timezone)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def from_local(local_dt, timezone=None):
|
|
35
|
-
"""Converts the given local datetime to a universal datetime."""
|
|
36
|
-
if not isinstance(local_dt, datetime.datetime):
|
|
37
|
-
raise TypeError('Expected a datetime object')
|
|
38
|
-
|
|
39
|
-
if timezone is None:
|
|
40
|
-
a = arrow.get(local_dt)
|
|
41
|
-
else:
|
|
42
|
-
a = arrow.get(local_dt, timezone)
|
|
43
|
-
return a.to('UTC').naive
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def from_unix(ut):
|
|
47
|
-
"""
|
|
48
|
-
Converts a UNIX timestamp, as returned by `time.time()`, to universal
|
|
49
|
-
time. Assumes the input is in UTC, as `time.time()` does.
|
|
50
|
-
"""
|
|
51
|
-
if not isinstance(ut, (int, float)):
|
|
52
|
-
raise TypeError('Expected an int or float value')
|
|
53
|
-
|
|
54
|
-
return arrow.get(ut).naive
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def to_local(dt, timezone):
|
|
58
|
-
"""Converts universal datetime to a local representation in given timezone."""
|
|
59
|
-
if dt.tzinfo is not None:
|
|
60
|
-
raise ValueError(
|
|
61
|
-
'First argument to to_local() should be a universal time.'
|
|
62
|
-
)
|
|
63
|
-
if not isinstance(timezone, string_types):
|
|
64
|
-
raise TypeError('expected a timezone name (string), but got {} instead'.format(type(timezone)))
|
|
65
|
-
return arrow.get(dt).to(timezone).datetime
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def to_unix(dt):
|
|
69
|
-
"""Converts a datetime object to unixtime"""
|
|
70
|
-
if not isinstance(dt, datetime.datetime):
|
|
71
|
-
raise TypeError('Expected a datetime object')
|
|
72
|
-
|
|
73
|
-
return arrow.get(dt).timestamp
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def format(dt, timezone, fmt=None):
|
|
77
|
-
"""Formats the given universal time for display in the given time zone."""
|
|
78
|
-
local = to_local(dt, timezone)
|
|
79
|
-
if fmt is None:
|
|
80
|
-
return local.isoformat()
|
|
81
|
-
else:
|
|
82
|
-
return local.strftime(fmt)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
now = datetime.datetime.utcnow
|
|
1
|
+
import datetime
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
import arrow
|
|
5
|
+
|
|
6
|
+
from .version import VERSION
|
|
7
|
+
|
|
8
|
+
PY3 = sys.version_info[0] == 3
|
|
9
|
+
if PY3:
|
|
10
|
+
string_types = str
|
|
11
|
+
else:
|
|
12
|
+
string_types = basestring
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
__author__ = 'Vincent Driessen <vincent@3rdcloud.com>'
|
|
16
|
+
__version__ = VERSION
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def to_universal(local_dt, timezone=None):
|
|
20
|
+
"""
|
|
21
|
+
Converts the given local datetime or UNIX timestamp to a universal
|
|
22
|
+
datetime.
|
|
23
|
+
"""
|
|
24
|
+
if isinstance(local_dt, (int, float)):
|
|
25
|
+
if timezone is not None:
|
|
26
|
+
raise ValueError('Timezone argument illegal when using UNIX timestamps.')
|
|
27
|
+
return from_unix(local_dt)
|
|
28
|
+
elif isinstance(local_dt, string_types):
|
|
29
|
+
local_dt = arrow.get(local_dt).to('UTC').naive
|
|
30
|
+
|
|
31
|
+
return from_local(local_dt, timezone)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def from_local(local_dt, timezone=None):
|
|
35
|
+
"""Converts the given local datetime to a universal datetime."""
|
|
36
|
+
if not isinstance(local_dt, datetime.datetime):
|
|
37
|
+
raise TypeError('Expected a datetime object')
|
|
38
|
+
|
|
39
|
+
if timezone is None:
|
|
40
|
+
a = arrow.get(local_dt)
|
|
41
|
+
else:
|
|
42
|
+
a = arrow.get(local_dt, timezone)
|
|
43
|
+
return a.to('UTC').naive
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def from_unix(ut):
|
|
47
|
+
"""
|
|
48
|
+
Converts a UNIX timestamp, as returned by `time.time()`, to universal
|
|
49
|
+
time. Assumes the input is in UTC, as `time.time()` does.
|
|
50
|
+
"""
|
|
51
|
+
if not isinstance(ut, (int, float)):
|
|
52
|
+
raise TypeError('Expected an int or float value')
|
|
53
|
+
|
|
54
|
+
return arrow.get(ut).naive
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def to_local(dt, timezone):
|
|
58
|
+
"""Converts universal datetime to a local representation in given timezone."""
|
|
59
|
+
if dt.tzinfo is not None:
|
|
60
|
+
raise ValueError(
|
|
61
|
+
'First argument to to_local() should be a universal time.'
|
|
62
|
+
)
|
|
63
|
+
if not isinstance(timezone, string_types):
|
|
64
|
+
raise TypeError('expected a timezone name (string), but got {} instead'.format(type(timezone)))
|
|
65
|
+
return arrow.get(dt).to(timezone).datetime
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def to_unix(dt):
|
|
69
|
+
"""Converts a datetime object to unixtime"""
|
|
70
|
+
if not isinstance(dt, datetime.datetime):
|
|
71
|
+
raise TypeError('Expected a datetime object')
|
|
72
|
+
|
|
73
|
+
return arrow.get(dt).timestamp
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def format(dt, timezone, fmt=None):
|
|
77
|
+
"""Formats the given universal time for display in the given time zone."""
|
|
78
|
+
local = to_local(dt, timezone)
|
|
79
|
+
if fmt is None:
|
|
80
|
+
return local.isoformat()
|
|
81
|
+
else:
|
|
82
|
+
return local.strftime(fmt)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
now = datetime.datetime.utcnow
|
funboost/utils/times/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.7'
|
|
1
|
+
VERSION = '0.7'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funboost
|
|
3
|
-
Version: 45.
|
|
3
|
+
Version: 45.7
|
|
4
4
|
Summary: pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和一切知名消息队列中间件,支持如 celery dramatiq等框架整体作为funboost中间件,python函数加速器,框架包罗万象,用户能想到的控制功能全都有。一统编程思维,兼容50% python业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数,99%用过funboost的pythoner 感受是 简易 方便 强劲 强大,相见恨晚
|
|
5
5
|
Home-page: https://github.com/ydf0509/funboost
|
|
6
6
|
Author: bfzs
|
|
@@ -27,7 +27,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
License-File: LICENSE
|
|
29
29
|
Requires-Dist: nb-log (>=12.6)
|
|
30
|
-
Requires-Dist: nb-libs (>=1.
|
|
30
|
+
Requires-Dist: nb-libs (>=1.8)
|
|
31
31
|
Requires-Dist: nb-time (>=1.8)
|
|
32
32
|
Requires-Dist: pymongo (==4.3.3)
|
|
33
33
|
Requires-Dist: AMQPStorm (==2.10.6)
|
|
@@ -132,16 +132,25 @@ Requires-Dist: flask-login ; extra == 'flask'
|
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
<pre style="color: greenyellow;background-color: #0c1119; font-size: medium;">
|
|
135
|
-
pip install funboost ,python
|
|
136
|
-
|
|
135
|
+
pip install funboost ,python全功能分布式函数调度框架。 demo用法例子见文档1.3
|
|
136
|
+
|
|
137
|
+
只需要一行@boost代码即可分布式执行python一切任意函数,99%用过funboost的pythoner 感受是 方便 快速 强大。
|
|
138
|
+
支持python所有类型的并发模式,消息队列方面支持全球一切知名消息队列中间件和模拟的实现消息队列,
|
|
137
139
|
同时funboost支持celery整个框架作为核心来发布和消费消息,使用funboost的极简api方式来自动化配置和利用celery调度,
|
|
138
140
|
也支持huey dramatiq rq等任务队列框架作为funboost的broker。
|
|
141
|
+
|
|
139
142
|
python函数加速器,框架包罗万象,一统编程思维,兼容50% python编程业务场景,适用范围广。
|
|
140
|
-
只需要一行代码即可分布式执行python一切函数,99%用过funboost的pythoner 感受是 方便 快速 强大。
|
|
141
143
|
python万能分布式函数调度框架,支持5种并发模式,30+种消息队列中间件(或任务队列框架),
|
|
142
144
|
30种任务控制功能。给任意python函数赋能。
|
|
143
145
|
用途概念就是常规经典的 生产者 + 消息队列中间件 + 消费者 编程思想。
|
|
146
|
+
|
|
144
147
|
框架只需要学习@boost这一个装饰器的入参就可以,所有用法几乎和1.3例子一摸一样,非常简化简单。
|
|
148
|
+
框架对代码没有入侵,可以加到任意已有项目而对项目python文件目录结构0要求,
|
|
149
|
+
不像 celery django scrapy 这样的框架,要从一开始就开始规划好项目目录结构,如果不想用框架了,
|
|
150
|
+
或者想改变使用其他框架框架,那么已经所写的代码组织形式就几乎成了废物,需要大改特改.
|
|
151
|
+
但是funboost完全不会这样,加上或去掉@boost装饰器,对你的项目影响为0,用户照常使用,
|
|
152
|
+
所以用户可以对任意项目,任意时候,引入使用funboost或者去掉使用funboost,代码组织形式不需要发生变化.
|
|
153
|
+
|
|
145
154
|
</pre>
|
|
146
155
|
|
|
147
156
|
### 框架评价
|
|
@@ -158,6 +167,7 @@ python万能分布式函数调度框架,支持5种并发模式,30+种消息
|
|
|
158
167
|
,连celery命令行运行起来都要反复猜测尝试。
|
|
159
168
|
正因为如此用户从心理已近十分惧怕学习一种叫python框架的东西了,用户顶多愿意学习一个python包或者模块,
|
|
160
169
|
学习一个框架会非常害怕觉得难度高且耗时,所以非常反感尝试新的框架。
|
|
170
|
+
用过的99%都说funboost比celery简单方便太多,看都不看的人第一秒就是开始质疑重复造轮子.
|
|
161
171
|
|
|
162
172
|
funboost只有一个@boost装饰器,@boost入参能自动补全,更重要的是被@boost装饰的函数,
|
|
163
173
|
有哪些方法,每个方法入参是什么都能自动补全。funboost的中间件配置文件自当生成在用户当前项目根目录,
|
|
@@ -296,10 +306,10 @@ if __name__ == '__main__':
|
|
|
296
306
|
2)funboost 使用内存队列,设置10线程并发
|
|
297
307
|
```python
|
|
298
308
|
import time
|
|
299
|
-
from funboost import
|
|
309
|
+
from funboost import BoosterParams, BrokerEnum
|
|
300
310
|
|
|
301
311
|
|
|
302
|
-
@
|
|
312
|
+
@BoosterParams(queue_name="test_insteda_thread_queue", broker_kind=BrokerEnum.MEMORY_QUEUE, concurrent_num=10, is_auto_start_consuming_message=True)
|
|
303
313
|
def f(x):
|
|
304
314
|
time.sleep(3)
|
|
305
315
|
print(x)
|
|
@@ -308,7 +318,8 @@ def f(x):
|
|
|
308
318
|
if __name__ == '__main__':
|
|
309
319
|
for i in range(100):
|
|
310
320
|
f.push(i)
|
|
311
|
-
|
|
321
|
+
|
|
322
|
+
|
|
312
323
|
```
|
|
313
324
|
|
|
314
325
|
|
|
@@ -563,7 +574,7 @@ python比其他语言更需要分布式函数调度框架来执行函数,有
|
|
|
563
574
|
funboost通过支持celery作为broker_kind,使celer框架变成了funboost的一个子集
|
|
564
575
|
```
|
|
565
576
|
|
|
566
|
-
[查看分布式函数调度框架完整文档](https://funboost.readthedocs.io/
|
|
577
|
+
[查看分布式函数调度框架完整文档](https://funboost.readthedocs.io/)
|
|
567
578
|
|
|
568
579
|
|
|
569
580
|
|
|
@@ -577,4 +588,3 @@ funboost通过支持celery作为broker_kind,使celer框架变成了funboost的
|
|
|
577
588
|

|
|
578
589
|
|
|
579
590
|
<div> </div>
|
|
580
|
-
|