serverish 1.2.2__tar.gz → 1.3.0__tar.gz
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.
- {serverish-1.2.2 → serverish-1.3.0}/PKG-INFO +2 -4
- {serverish-1.2.2 → serverish-1.3.0}/pyproject.toml +2 -2
- serverish-1.3.0/serverish/base/iterators.py +97 -0
- {serverish-1.2.2 → serverish-1.3.0}/LICENSE +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/README.md +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/__init__.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/__init__.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/asyncio_util_functions.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/collector.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/datetime.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/exceptions.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/fifoset.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/hasstatuses.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/idmanger.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/manageable.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/singleton.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/status.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/base/task_manager.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/connection/__init__.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/connection/connection.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/connection/connection_jets.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/connection/connection_nats.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/__init__.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/logging.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/messenger.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_callback_sub.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_journal_pub.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_journal_read.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_progress_pub.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_progress_read.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_publisher.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_reader.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_rpc_req.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_rpc_resp.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_single_pub.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msg_single_read.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/messenger/msgvalidator.py +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/config.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/default.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/include/timestamp.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/journal.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/meta.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/program_current_state.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/program_state.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/progress.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/schema/telemetry.schema.json +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/services/TODO.txt +0 -0
- {serverish-1.2.2 → serverish-1.3.0}/serverish/slog.py +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: serverish
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: helpers for server alike projects
|
|
5
5
|
Home-page: https://github.com/AkondLab/serverish
|
|
6
6
|
Author: Mikołaj Kałuszyński
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "serverish"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.3.0"
|
|
4
4
|
description = "helpers for server alike projects"
|
|
5
5
|
authors = ["Mikołaj Kałuszyński", "MMME team"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -8,7 +8,7 @@ repository = "https://github.com/AkondLab/serverish"
|
|
|
8
8
|
include = ["serverish/schema/*"]
|
|
9
9
|
|
|
10
10
|
[tool.poetry.dependencies]
|
|
11
|
-
python = "^3.
|
|
11
|
+
python = "^3.10"
|
|
12
12
|
aiodns = {version="^3.2.0", optional=true}
|
|
13
13
|
param = "^2.1.0"
|
|
14
14
|
nats-py = { version = "^2.7.2", optional= true}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from typing import List, Dict, Any, Tuple, Set
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AsyncRangeIter:
|
|
6
|
+
"""This class represent async range iterator (instead of sync).
|
|
7
|
+
|
|
8
|
+
WARNING: Noticed that end is included (not like in standard iterator).
|
|
9
|
+
Example 1: start=1, end=4, will return [1, 2, 3, 4]
|
|
10
|
+
Example 2: async for n in AsyncRangeIter(start=1, end=3): ...
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, start: int, end: int) -> None:
|
|
14
|
+
self.start = start
|
|
15
|
+
self.end = end
|
|
16
|
+
|
|
17
|
+
def __aiter__(self) -> Any:
|
|
18
|
+
self.current = self.start
|
|
19
|
+
return self
|
|
20
|
+
|
|
21
|
+
async def __anext__(self) -> int:
|
|
22
|
+
if self.current <= self.end:
|
|
23
|
+
value = self.current
|
|
24
|
+
self.current += 1
|
|
25
|
+
await asyncio.sleep(0)
|
|
26
|
+
return value
|
|
27
|
+
else:
|
|
28
|
+
raise StopAsyncIteration
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AsyncListIter:
|
|
32
|
+
"""This class represent async list iterator (instead of sync).
|
|
33
|
+
|
|
34
|
+
Example of use: async for n in AsyncListIter(some_list): ...
|
|
35
|
+
"""
|
|
36
|
+
def __init__(self, iterable: List | Tuple | Set | Any):
|
|
37
|
+
self.iterable = iterable
|
|
38
|
+
self.index: int = 0
|
|
39
|
+
|
|
40
|
+
def __aiter__(self) -> Any:
|
|
41
|
+
self.index = 0
|
|
42
|
+
return self
|
|
43
|
+
|
|
44
|
+
async def __anext__(self):
|
|
45
|
+
if self.index < len(self.iterable):
|
|
46
|
+
value = self.iterable[self.index]
|
|
47
|
+
self.index += 1
|
|
48
|
+
await asyncio.sleep(0)
|
|
49
|
+
return value
|
|
50
|
+
else:
|
|
51
|
+
raise StopAsyncIteration
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class AsyncEnumerateIter:
|
|
55
|
+
"""This class represent async enumerate iterator (instead of sync).
|
|
56
|
+
|
|
57
|
+
Example of use: async for current_index, value in AsyncEnumerateIter(some_iterable): ...
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def __init__(self, iterable: List | Tuple | Set | Any) -> None:
|
|
61
|
+
self.iterable = iterable
|
|
62
|
+
|
|
63
|
+
def __aiter__(self):
|
|
64
|
+
self.index = 0
|
|
65
|
+
return self
|
|
66
|
+
|
|
67
|
+
async def __anext__(self):
|
|
68
|
+
if self.index < len(self.iterable):
|
|
69
|
+
value = self.iterable[self.index]
|
|
70
|
+
current_index = self.index
|
|
71
|
+
self.index += 1
|
|
72
|
+
await asyncio.sleep(0)
|
|
73
|
+
return current_index, value
|
|
74
|
+
else:
|
|
75
|
+
raise StopAsyncIteration
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class AsyncDictItemsIter:
|
|
79
|
+
"""This class represent async dict items iterator (instead of sync).
|
|
80
|
+
|
|
81
|
+
Example of use: async for key, value in AsyncEnumerateIter(some_dict): ...
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
def __init__(self, data_dict: Dict) -> None:
|
|
85
|
+
self.data_dict = data_dict
|
|
86
|
+
|
|
87
|
+
def __aiter__(self) -> Any:
|
|
88
|
+
self.iterator = iter(self.data_dict.items())
|
|
89
|
+
return self
|
|
90
|
+
|
|
91
|
+
async def __anext__(self) -> Tuple:
|
|
92
|
+
try:
|
|
93
|
+
n, m = next(self.iterator)
|
|
94
|
+
await asyncio.sleep(0)
|
|
95
|
+
return n, m
|
|
96
|
+
except StopIteration:
|
|
97
|
+
raise StopAsyncIteration
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|