DefStream 0.1.11__tar.gz → 0.1.12__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.
- {defstream-0.1.11 → defstream-0.1.12}/DefStream.egg-info/PKG-INFO +1 -1
- {defstream-0.1.11 → defstream-0.1.12}/DefStream.egg-info/SOURCES.txt +1 -0
- {defstream-0.1.11 → defstream-0.1.12}/PKG-INFO +1 -1
- defstream-0.1.12/issues/fix/13/README.md +31 -0
- {defstream-0.1.11 → defstream-0.1.12}/sample/Worker/RabbitMQ/Client.py +2 -2
- {defstream-0.1.11 → defstream-0.1.12}/sample/Worker/RabbitMQ/Tasks.py +23 -1
- {defstream-0.1.11 → defstream-0.1.12}/sample/Worker/RabbitMQ/Worker.py +7 -4
- {defstream-0.1.11 → defstream-0.1.12}/sample/Worker/Redis/Sample.py +22 -15
- {defstream-0.1.11 → defstream-0.1.12}/sample/Worker/Sample.py +25 -16
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Startup.py +42 -3
- {defstream-0.1.11 → defstream-0.1.12}/test/test_logging.py +1 -1
- {defstream-0.1.11 → defstream-0.1.12}/.github/workflows/ci.yml +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/.gitignore +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/DefStream.egg-info/dependency_links.txt +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/DefStream.egg-info/requires.txt +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/DefStream.egg-info/top_level.txt +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/LICENSE +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/README.en.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/README.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/1/IMPLEMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/1/README.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/1/REQUIREMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/1/TASK.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/1/ci.refs.json +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/8/IMPLEMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/8/README.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/8/REQUIREMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/feature/8/ci.refs.json +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/10/IMPLEMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/10/README.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/10/REQUIREMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/3/IMPLEMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/3/README.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/3/REQUIREMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/3/ci.refs.json +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/6/IMPLEMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/6/README.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/issues/fix/6/REQUIREMENTS.md +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/sample/Broker/Sample.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/setup.cfg +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/setup.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Configuration.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Connection.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Consumer.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Errors.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Event.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Implements/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Policies.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Priority.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/Protocol.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Broker/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Descriptor/DataObject.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Descriptor/Types.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Descriptor/Value.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Descriptor/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extension.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/Console.html +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/Console.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/Dashboard.html +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/Dashboard.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/HealthCheck.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/Metrics.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/Specifications.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Extensions/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Inspector.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/Response.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Inspector/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Pattern.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Array.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Common.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Compare.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Condition.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/DataObject.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/DateTime.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Number.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Object.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Size.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/String.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/Type.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Patterns/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Validate.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/Validator.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Validator/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Executor.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Message.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Pool.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Run.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Specification.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/Worker.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/Worker/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/src/__init__.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_dashboard.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_dashboard_ui.cjs +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_descriptor.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_inspector.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_inspector_console.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_inspector_logging.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_lifecycle_hooks.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_pool_callbacks.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_process_signals.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_protocol_contracts.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_release_workflow.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_runner_hooks.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_specifications.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_task_messages.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_task_priorities.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_worker.py +0 -0
- {defstream-0.1.11 → defstream-0.1.12}/test/test_worker_startup.py +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Worker 시작 배너와 샘플 로깅 순서
|
|
2
|
+
|
|
3
|
+
## 변경 요약
|
|
4
|
+
|
|
5
|
+
Worker 시작 배너를 로깅 설정 여부와 관계없이 먼저 확인할 수 있도록 Worker
|
|
6
|
+
샘플의 로깅 설정 시점을 `WorkerSetup` 훅으로 옮겼습니다. 시작 배너는 터미널에서
|
|
7
|
+
청록·파랑 계열로 강조하며, ASCII 아트의 모양과 문구는 유지합니다.
|
|
8
|
+
|
|
9
|
+
## 변경 내용
|
|
10
|
+
|
|
11
|
+
- [Worker 샘플](../../../sample/Worker/Sample.py)은 `configure_logging()`을
|
|
12
|
+
실행 진입점에서 호출하는 대신 `SetupLogger` setup 훅에서 수행합니다.
|
|
13
|
+
Worker 생성·작업 등록 시점의 로그는 아직 설정되지 않은 핸들러에 의해 출력되지
|
|
14
|
+
않으며, 시작 배너가 샘플의 첫 화면 출력이 됩니다.
|
|
15
|
+
- [Startup](../../../src/Worker/Startup.py)은 stdout이 터미널이고 `NO_COLOR`
|
|
16
|
+
환경 변수가 설정되지 않은 경우에만 로고에 색을 적용합니다. `Starting Worker`
|
|
17
|
+
제목도 굵은 청록색으로 표시합니다. 파일·파이프 등으로 출력을 리다이렉트하거나
|
|
18
|
+
`NO_COLOR`를 설정하면 ANSI 색상 코드를 출력하지 않습니다.
|
|
19
|
+
- `Worker.run()`의 로그와 배너 호출 순서는 변경하지 않았습니다. 따라서
|
|
20
|
+
로깅 핸들러가 미리 설정된 애플리케이션에서는 `Starting Worker` 로그가 배너보다
|
|
21
|
+
먼저 기록될 수 있습니다. 이 변경은 샘플의 로깅 설정 시점을 조정해 샘플 출력에서
|
|
22
|
+
배너를 먼저 보이게 합니다.
|
|
23
|
+
|
|
24
|
+
## 호환성 및 검증 범위
|
|
25
|
+
|
|
26
|
+
시작 배너의 ASCII 문자와 구성 출력은 유지됩니다. 색상은 터미널 조건에서만
|
|
27
|
+
추가되며 `NO_COLOR`를 통해 끌 수 있습니다.
|
|
28
|
+
|
|
29
|
+
로고 색상 적용 후 ANSI 코드를 제거한 결과가 원본과 동일한지, 수정한 Python 소스의
|
|
30
|
+
문법이 유효한지 확인했습니다. Worker 시작 테스트는 환경에 `pika`가 없어 실행하지
|
|
31
|
+
못했으며, 샘플의 로깅 순서 변경은 별도 실행으로 검증하지 않았습니다.
|
|
@@ -3,7 +3,7 @@ from random import randint
|
|
|
3
3
|
from Tasks import (
|
|
4
4
|
Add,
|
|
5
5
|
Divide,
|
|
6
|
-
|
|
6
|
+
TaskLoggingSetup,
|
|
7
7
|
logger,
|
|
8
8
|
)
|
|
9
9
|
|
|
@@ -16,7 +16,7 @@ from DefStream.Worker import request
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
if __name__ == '__main__':
|
|
19
|
-
|
|
19
|
+
TaskLoggingSetup()()
|
|
20
20
|
broker = Connection(Configuration(
|
|
21
21
|
host='127.0.0.1',
|
|
22
22
|
port=5672,
|
|
@@ -28,9 +28,11 @@ from DefStream.Validator.Patterns.Object import (
|
|
|
28
28
|
IsRequiredIn,
|
|
29
29
|
)
|
|
30
30
|
from DefStream.Worker import (
|
|
31
|
+
WorkerSetup,
|
|
31
32
|
PoolSetup,
|
|
32
33
|
Run,
|
|
33
34
|
Specification,
|
|
35
|
+
Worker,
|
|
34
36
|
)
|
|
35
37
|
|
|
36
38
|
__all__ = (
|
|
@@ -42,7 +44,27 @@ __all__ = (
|
|
|
42
44
|
logger = getLogger('Sample')
|
|
43
45
|
|
|
44
46
|
|
|
45
|
-
class
|
|
47
|
+
class SetupLogger(WorkerSetup):
|
|
48
|
+
"""부모와 spawn 자식 프로세스의 샘플 로그 출력을 설정한다."""
|
|
49
|
+
|
|
50
|
+
def __call__(
|
|
51
|
+
self,
|
|
52
|
+
worker: Worker,
|
|
53
|
+
) -> None:
|
|
54
|
+
handler = StreamHandler()
|
|
55
|
+
handler.setFormatter(Formatter('%(asctime)s %(processName)s %(name)s %(levelname)s %(message)s'))
|
|
56
|
+
sources = (
|
|
57
|
+
Filter('Sample'),
|
|
58
|
+
Filter('DefStream'),
|
|
59
|
+
)
|
|
60
|
+
handler.addFilter(lambda record: any(source.filter(record) for source in sources))
|
|
61
|
+
root = getLogger()
|
|
62
|
+
root.setLevel(DEBUG)
|
|
63
|
+
root.addHandler(handler)
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class TaskLoggingSetup(PoolSetup):
|
|
46
68
|
"""부모와 spawn 자식 프로세스의 샘플 로그 출력을 설정한다."""
|
|
47
69
|
|
|
48
70
|
def __call__(self) -> None:
|
|
@@ -7,7 +7,8 @@ from signal import (
|
|
|
7
7
|
from Tasks import (
|
|
8
8
|
Add,
|
|
9
9
|
Divide,
|
|
10
|
-
|
|
10
|
+
TaskLoggingSetup,
|
|
11
|
+
SetupLogger,
|
|
11
12
|
logger,
|
|
12
13
|
)
|
|
13
14
|
|
|
@@ -76,7 +77,6 @@ class Cleanup(WorkerCleanup):
|
|
|
76
77
|
|
|
77
78
|
|
|
78
79
|
if __name__ == '__main__':
|
|
79
|
-
LoggingSetup()()
|
|
80
80
|
worker = Worker(
|
|
81
81
|
Connection(Configuration(
|
|
82
82
|
host='127.0.0.1',
|
|
@@ -86,9 +86,12 @@ if __name__ == '__main__':
|
|
|
86
86
|
)),
|
|
87
87
|
ProcessPool(
|
|
88
88
|
10,
|
|
89
|
-
setups=
|
|
89
|
+
setups=TaskLoggingSetup(),
|
|
90
|
+
),
|
|
91
|
+
setups=(
|
|
92
|
+
SetupLogger(),
|
|
93
|
+
Prepare(),
|
|
90
94
|
),
|
|
91
|
-
setups=Prepare(),
|
|
92
95
|
cleanups=Cleanup(),
|
|
93
96
|
inspector=Inspector(
|
|
94
97
|
host='127.0.0.1',
|
|
@@ -39,19 +39,6 @@ from DefStream.Worker import (
|
|
|
39
39
|
logger = getLogger('Sample')
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def configure_logging() -> None:
|
|
43
|
-
handler = StreamHandler()
|
|
44
|
-
handler.setFormatter(Formatter('%(asctime)s %(name)s %(levelname)s %(message)s'))
|
|
45
|
-
sources = (
|
|
46
|
-
Filter('Sample'),
|
|
47
|
-
Filter('DefStream'),
|
|
48
|
-
)
|
|
49
|
-
handler.addFilter(lambda record: any(source.filter(record) for source in sources))
|
|
50
|
-
root = getLogger()
|
|
51
|
-
root.setLevel(DEBUG)
|
|
52
|
-
root.addHandler(handler)
|
|
53
|
-
return
|
|
54
|
-
|
|
55
42
|
|
|
56
43
|
class Add(
|
|
57
44
|
Run,
|
|
@@ -96,6 +83,24 @@ class Divide(
|
|
|
96
83
|
return result
|
|
97
84
|
|
|
98
85
|
|
|
86
|
+
class SetupLogger(WorkerSetup):
|
|
87
|
+
def __call__(
|
|
88
|
+
self,
|
|
89
|
+
worker: Worker,
|
|
90
|
+
) -> None:
|
|
91
|
+
handler = StreamHandler()
|
|
92
|
+
handler.setFormatter(Formatter('%(asctime)s %(name)s %(levelname)s %(message)s'))
|
|
93
|
+
sources = (
|
|
94
|
+
Filter('Sample'),
|
|
95
|
+
Filter('DefStream'),
|
|
96
|
+
)
|
|
97
|
+
handler.addFilter(lambda record: any(source.filter(record) for source in sources))
|
|
98
|
+
root = getLogger()
|
|
99
|
+
root.setLevel(DEBUG)
|
|
100
|
+
root.addHandler(handler)
|
|
101
|
+
return
|
|
102
|
+
|
|
103
|
+
|
|
99
104
|
class Prepare(WorkerSetup):
|
|
100
105
|
def __call__(
|
|
101
106
|
self,
|
|
@@ -139,11 +144,13 @@ class Cleanup(WorkerCleanup):
|
|
|
139
144
|
|
|
140
145
|
|
|
141
146
|
def main() -> None:
|
|
142
|
-
configure_logging()
|
|
143
147
|
worker = Worker(
|
|
144
148
|
Connection(Configuration()),
|
|
145
149
|
ThreadPool(10),
|
|
146
|
-
setups=
|
|
150
|
+
setups=(
|
|
151
|
+
SetupLogger(),
|
|
152
|
+
Prepare(),
|
|
153
|
+
),
|
|
147
154
|
cleanups=Cleanup(),
|
|
148
155
|
inspector=Inspector(
|
|
149
156
|
host='127.0.0.1',
|
|
@@ -35,19 +35,6 @@ from DefStream.Worker import (
|
|
|
35
35
|
logger = getLogger('Sample')
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def configure_logging() -> None:
|
|
39
|
-
handler = StreamHandler()
|
|
40
|
-
handler.setFormatter(Formatter('%(asctime)s %(name)s %(levelname)s %(message)s'))
|
|
41
|
-
sources = (
|
|
42
|
-
Filter('Sample'),
|
|
43
|
-
Filter('DefStream'),
|
|
44
|
-
)
|
|
45
|
-
handler.addFilter(lambda record: any(source.filter(record) for source in sources))
|
|
46
|
-
root = getLogger()
|
|
47
|
-
root.setLevel(DEBUG)
|
|
48
|
-
root.addHandler(handler)
|
|
49
|
-
return
|
|
50
|
-
|
|
51
38
|
|
|
52
39
|
class Queue(Sendable):
|
|
53
40
|
def __init__(self):
|
|
@@ -219,6 +206,24 @@ class Add(
|
|
|
219
206
|
)
|
|
220
207
|
|
|
221
208
|
|
|
209
|
+
class SetupLogger(WorkerSetup):
|
|
210
|
+
def __call__(
|
|
211
|
+
self,
|
|
212
|
+
worker: Worker,
|
|
213
|
+
) -> None:
|
|
214
|
+
handler = StreamHandler()
|
|
215
|
+
handler.setFormatter(Formatter('%(asctime)s %(name)s %(levelname)s %(message)s'))
|
|
216
|
+
sources = (
|
|
217
|
+
Filter('Sample'),
|
|
218
|
+
Filter('DefStream'),
|
|
219
|
+
)
|
|
220
|
+
handler.addFilter(lambda record: any(source.filter(record) for source in sources))
|
|
221
|
+
root = getLogger()
|
|
222
|
+
root.setLevel(DEBUG)
|
|
223
|
+
root.addHandler(handler)
|
|
224
|
+
return
|
|
225
|
+
|
|
226
|
+
|
|
222
227
|
class Prepare(WorkerSetup):
|
|
223
228
|
def __call__(
|
|
224
229
|
self,
|
|
@@ -252,12 +257,16 @@ class Cleanup(WorkerCleanup):
|
|
|
252
257
|
|
|
253
258
|
|
|
254
259
|
if __name__ == '__main__':
|
|
255
|
-
configure_logging()
|
|
256
260
|
worker = Worker(
|
|
257
261
|
Broker(),
|
|
258
262
|
ThreadPool(1),
|
|
259
|
-
setups=
|
|
260
|
-
|
|
263
|
+
setups=(
|
|
264
|
+
SetupLogger(),
|
|
265
|
+
Prepare(),
|
|
266
|
+
),
|
|
267
|
+
cleanups=(
|
|
268
|
+
Cleanup(),
|
|
269
|
+
),
|
|
261
270
|
)
|
|
262
271
|
worker.add(Add)
|
|
263
272
|
worker.run()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from collections.abc import Mapping
|
|
2
|
-
from os import getpid
|
|
2
|
+
from os import environ, getpid
|
|
3
|
+
import sys
|
|
3
4
|
from typing import (
|
|
4
5
|
Any,
|
|
5
6
|
TYPE_CHECKING,
|
|
@@ -19,9 +20,42 @@ LOGO = r"""
|
|
|
19
20
|
███ ███ ▄█▀█▄ ▀██▀ ▀████▄ ▀██▀▀ ████▄ ▄█▀█▄ ▀▀█▄ ███▄███▄
|
|
20
21
|
███ ███ ██▄█▀ ██ ▀████ ██ ██ ▀▀ ██▄█▀ ▄█▀██ ██ ██ ██
|
|
21
22
|
██████▀ ▀█▄▄▄ ██ ███████▀ ██ ██ ▀█▄▄▄ ▀█▄██ ██ ██ ██
|
|
23
|
+
|
|
24
|
+
Just def. Let workers do the work. You don't need to await this.
|
|
22
25
|
"""
|
|
23
26
|
|
|
24
27
|
|
|
28
|
+
def supports_color() -> bool:
|
|
29
|
+
return (
|
|
30
|
+
getattr(sys.stdout, 'isatty', lambda: False)()
|
|
31
|
+
and not environ.get('NO_COLOR')
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def colorize_logo(logo: str) -> str:
|
|
36
|
+
colors = (
|
|
37
|
+
'\033[38;5;39m',
|
|
38
|
+
'\033[38;5;45m',
|
|
39
|
+
'\033[38;5;51m',
|
|
40
|
+
'\033[38;5;45m',
|
|
41
|
+
'\033[38;5;39m',
|
|
42
|
+
)
|
|
43
|
+
reset = '\033[0m'
|
|
44
|
+
colorized_lines = []
|
|
45
|
+
art_line = 0
|
|
46
|
+
for line in logo.splitlines(keepends=True):
|
|
47
|
+
if line.strip() and art_line < len(colors):
|
|
48
|
+
newline = '\n' if line.endswith('\n') else ''
|
|
49
|
+
colorized_lines.append(
|
|
50
|
+
f'{colors[art_line]}{line[:-1] if newline else line}'
|
|
51
|
+
f'{reset}{newline}',
|
|
52
|
+
)
|
|
53
|
+
art_line += 1
|
|
54
|
+
else:
|
|
55
|
+
colorized_lines.append(line)
|
|
56
|
+
return ''.join(colorized_lines)
|
|
57
|
+
|
|
58
|
+
|
|
25
59
|
def subscription_value(
|
|
26
60
|
parameters: Any,
|
|
27
61
|
name: str,
|
|
@@ -90,10 +124,15 @@ def startup(worker: 'Worker') -> None:
|
|
|
90
124
|
str,
|
|
91
125
|
) and vhost:
|
|
92
126
|
broker_name += '/' + vhost.lstrip('/')
|
|
127
|
+
logo = LOGO.rstrip()
|
|
128
|
+
starting_worker = 'Starting Worker'
|
|
129
|
+
if supports_color():
|
|
130
|
+
logo = colorize_logo(logo)
|
|
131
|
+
starting_worker = f'\033[1;38;5;51m{starting_worker}\033[0m'
|
|
93
132
|
lines = [
|
|
94
|
-
|
|
133
|
+
logo,
|
|
95
134
|
'',
|
|
96
|
-
|
|
135
|
+
starting_worker,
|
|
97
136
|
f' PID: {getpid()}',
|
|
98
137
|
f' Broker: {broker_name}',
|
|
99
138
|
]
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|