PyFunceble-dev 4.3.0a15__py3-none-any.whl → 4.3.0a16__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.
- PyFunceble/__init__.py +1 -1
- PyFunceble/checker/__init__.py +1 -1
- PyFunceble/checker/availability/__init__.py +1 -1
- PyFunceble/checker/availability/base.py +36 -33
- PyFunceble/checker/availability/domain.py +1 -1
- PyFunceble/checker/availability/domain_and_ip.py +1 -1
- PyFunceble/checker/availability/extras/__init__.py +1 -1
- PyFunceble/checker/availability/extras/base.py +4 -4
- PyFunceble/checker/availability/extras/dns.py +1 -1
- PyFunceble/checker/availability/extras/etoxic.py +1 -1
- PyFunceble/checker/availability/extras/external.py +1 -1
- PyFunceble/checker/availability/extras/parked.py +1 -1
- PyFunceble/checker/availability/extras/rules.py +1 -1
- PyFunceble/checker/availability/extras/subject_switch.py +1 -1
- PyFunceble/checker/availability/ip.py +1 -1
- PyFunceble/checker/availability/params.py +1 -1
- PyFunceble/checker/availability/status.py +1 -1
- PyFunceble/checker/availability/url.py +1 -1
- PyFunceble/checker/base.py +1 -1
- PyFunceble/checker/complex_json_encoder.py +1 -1
- PyFunceble/checker/params_base.py +1 -1
- PyFunceble/checker/reputation/__init__.py +1 -1
- PyFunceble/checker/reputation/base.py +1 -1
- PyFunceble/checker/reputation/domain.py +1 -1
- PyFunceble/checker/reputation/domain_and_ip.py +1 -1
- PyFunceble/checker/reputation/ip.py +1 -1
- PyFunceble/checker/reputation/params.py +1 -1
- PyFunceble/checker/reputation/status.py +1 -1
- PyFunceble/checker/reputation/url.py +1 -1
- PyFunceble/checker/status_base.py +1 -1
- PyFunceble/checker/syntax/__init__.py +1 -1
- PyFunceble/checker/syntax/base.py +1 -1
- PyFunceble/checker/syntax/domain.py +1 -1
- PyFunceble/checker/syntax/domain_and_ip.py +1 -1
- PyFunceble/checker/syntax/domain_base.py +1 -1
- PyFunceble/checker/syntax/ip.py +1 -1
- PyFunceble/checker/syntax/ipv4.py +1 -1
- PyFunceble/checker/syntax/ipv6.py +1 -1
- PyFunceble/checker/syntax/params.py +1 -1
- PyFunceble/checker/syntax/second_lvl_domain.py +1 -1
- PyFunceble/checker/syntax/status.py +1 -1
- PyFunceble/checker/syntax/subdomain.py +1 -1
- PyFunceble/checker/syntax/url.py +1 -1
- PyFunceble/checker/utils/__init__.py +1 -1
- PyFunceble/checker/utils/whois.py +1 -1
- PyFunceble/cli/__init__.py +1 -1
- PyFunceble/cli/continuous_integration/__init__.py +1 -1
- PyFunceble/cli/continuous_integration/base.py +1 -1
- PyFunceble/cli/continuous_integration/exceptions.py +1 -1
- PyFunceble/cli/continuous_integration/github_actions.py +1 -1
- PyFunceble/cli/continuous_integration/gitlab_ci.py +1 -1
- PyFunceble/cli/continuous_integration/jenkins.py +1 -1
- PyFunceble/cli/continuous_integration/standalone.py +1 -1
- PyFunceble/cli/continuous_integration/travis_ci.py +1 -1
- PyFunceble/cli/continuous_integration/utils.py +1 -1
- PyFunceble/cli/credential_loader.py +1 -1
- PyFunceble/cli/entry_points/__init__.py +1 -1
- PyFunceble/cli/entry_points/clean.py +1 -1
- PyFunceble/cli/entry_points/iana.py +1 -1
- PyFunceble/cli/entry_points/production.py +1 -1
- PyFunceble/cli/entry_points/public_suffix.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/__init__.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/argsparser.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/cli.py +2 -2
- PyFunceble/cli/execution_time.py +1 -1
- PyFunceble/cli/facility.py +1 -1
- PyFunceble/cli/factory.py +1 -1
- PyFunceble/cli/file_preloader.py +1 -1
- PyFunceble/cli/filesystem/__init__.py +1 -1
- PyFunceble/cli/filesystem/cleanup.py +1 -1
- PyFunceble/cli/filesystem/counter.py +1 -1
- PyFunceble/cli/filesystem/dir_base.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/__init__.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/backup.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/base.py +1 -1
- PyFunceble/cli/filesystem/dir_structure/restore.py +1 -1
- PyFunceble/cli/filesystem/json_base.py +1 -1
- PyFunceble/cli/filesystem/printer/__init__.py +1 -1
- PyFunceble/cli/filesystem/printer/base.py +1 -1
- PyFunceble/cli/filesystem/printer/file.py +1 -1
- PyFunceble/cli/filesystem/printer/stdout.py +1 -1
- PyFunceble/cli/filesystem/registrar_counter.py +1 -1
- PyFunceble/cli/filesystem/status_file.py +1 -1
- PyFunceble/cli/migrators/__init__.py +1 -1
- PyFunceble/cli/migrators/alembic.py +1 -1
- PyFunceble/cli/migrators/base.py +1 -1
- PyFunceble/cli/migrators/csv_file/__init__.py +1 -1
- PyFunceble/cli/migrators/csv_file/base.py +1 -1
- PyFunceble/cli/migrators/csv_file/inactive_source_delete.py +1 -1
- PyFunceble/cli/migrators/csv_file/whois_registrar_add.py +1 -1
- PyFunceble/cli/migrators/db_base.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/__init__.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/base.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/hashes_file.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/mining_file.py +1 -1
- PyFunceble/cli/migrators/file_cleanup/production_config_file.py +1 -1
- PyFunceble/cli/migrators/json2csv/__init__.py +1 -1
- PyFunceble/cli/migrators/json2csv/base.py +1 -1
- PyFunceble/cli/migrators/json2csv/inactive.py +1 -1
- PyFunceble/cli/migrators/json2csv/whois.py +1 -1
- PyFunceble/cli/migrators/mariadb/__init__.py +1 -1
- PyFunceble/cli/migrators/mariadb/base.py +1 -1
- PyFunceble/cli/migrators/mariadb/file_and_status.py +1 -1
- PyFunceble/cli/migrators/mariadb/whois_record_idna_subject.py +1 -1
- PyFunceble/cli/processes/__init__.py +1 -1
- PyFunceble/cli/processes/base.py +4 -442
- PyFunceble/cli/processes/chancy_producer.py +3 -2
- PyFunceble/cli/processes/chancy_tester.py +3 -2
- PyFunceble/cli/processes/dir_files_sorter.py +3 -2
- PyFunceble/cli/processes/file_sorter.py +3 -2
- PyFunceble/cli/processes/migrator.py +25 -14
- PyFunceble/cli/processes/miner.py +3 -2
- PyFunceble/cli/processes/producer.py +3 -2
- PyFunceble/cli/processes/tester.py +3 -2
- PyFunceble/cli/processes/workers/__init__.py +1 -1
- PyFunceble/cli/processes/workers/base.py +33 -324
- PyFunceble/cli/processes/workers/chancy_producer.py +1 -3
- PyFunceble/cli/processes/workers/chancy_tester.py +5 -5
- PyFunceble/cli/processes/workers/dir_files_sorter.py +8 -3
- PyFunceble/cli/processes/workers/file_sorter.py +8 -3
- PyFunceble/cli/processes/workers/file_sorter_base.py +1 -1
- PyFunceble/cli/processes/workers/migrator.py +5 -3
- PyFunceble/cli/processes/workers/miner.py +10 -5
- PyFunceble/cli/processes/workers/producer.py +15 -8
- PyFunceble/cli/processes/workers/tester.py +5 -5
- PyFunceble/cli/scripts/__init__.py +1 -1
- PyFunceble/cli/scripts/iana.py +1 -1
- PyFunceble/cli/scripts/production.py +1 -1
- PyFunceble/cli/scripts/public_suffix.py +1 -1
- PyFunceble/cli/storage.py +1 -1
- PyFunceble/cli/storage_facility.py +1 -1
- PyFunceble/cli/system/__init__.py +1 -1
- PyFunceble/cli/system/base.py +2 -2
- PyFunceble/cli/system/integrator.py +2 -1
- PyFunceble/cli/system/launcher.py +81 -57
- PyFunceble/cli/utils/__init__.py +1 -1
- PyFunceble/cli/utils/ascii_logo.py +1 -1
- PyFunceble/cli/utils/sort.py +1 -1
- PyFunceble/cli/utils/stdout.py +1 -1
- PyFunceble/cli/utils/testing.py +1 -1
- PyFunceble/cli/utils/version.py +1 -1
- PyFunceble/config/__init__.py +1 -1
- PyFunceble/config/compare.py +1 -1
- PyFunceble/config/loader.py +1 -1
- PyFunceble/converter/__init__.py +1 -1
- PyFunceble/converter/adblock_input_line2subject.py +1 -1
- PyFunceble/converter/base.py +1 -1
- PyFunceble/converter/cidr2subject.py +1 -1
- PyFunceble/converter/input_line2subject.py +1 -1
- PyFunceble/converter/internal_url.py +1 -1
- PyFunceble/converter/rpz_input_line2subject.py +1 -1
- PyFunceble/converter/rpz_policy2subject.py +1 -1
- PyFunceble/converter/subject2complements.py +1 -1
- PyFunceble/converter/url2netloc.py +1 -1
- PyFunceble/converter/wildcard2subject.py +1 -1
- PyFunceble/data/alembic/__init__.py +1 -1
- PyFunceble/data/alembic/mysql/__init__.py +1 -1
- PyFunceble/data/alembic/mysql/env.py +1 -1
- PyFunceble/data/alembic/mysql/versions/__init__.py +1 -1
- PyFunceble/data/alembic/postgresql/__init__.py +1 -1
- PyFunceble/data/alembic/postgresql/env.py +1 -1
- PyFunceble/data/alembic/postgresql/versions/__init__.py +1 -1
- PyFunceble/database/__init__.py +1 -1
- PyFunceble/database/credential/__init__.py +1 -1
- PyFunceble/database/credential/base.py +1 -1
- PyFunceble/database/credential/mariadb.py +1 -1
- PyFunceble/database/credential/mysql.py +1 -1
- PyFunceble/database/credential/postgresql.py +1 -1
- PyFunceble/database/schemas/__init__.py +1 -1
- PyFunceble/database/schemas/autocontinue.py +1 -1
- PyFunceble/database/schemas/inactive.py +1 -1
- PyFunceble/database/schemas/status.py +1 -1
- PyFunceble/database/schemas/whois_record.py +1 -1
- PyFunceble/database/session.py +1 -1
- PyFunceble/database/sqlalchemy/__init__.py +1 -1
- PyFunceble/database/sqlalchemy/all_schemas.py +1 -1
- PyFunceble/database/sqlalchemy/base_schema.py +1 -1
- PyFunceble/dataset/__init__.py +1 -1
- PyFunceble/dataset/autocontinue/__init__.py +1 -1
- PyFunceble/dataset/autocontinue/base.py +1 -1
- PyFunceble/dataset/autocontinue/csv.py +1 -1
- PyFunceble/dataset/autocontinue/sql.py +1 -1
- PyFunceble/dataset/base.py +2 -2
- PyFunceble/dataset/csv_base.py +1 -1
- PyFunceble/dataset/db_base.py +1 -1
- PyFunceble/dataset/iana.py +1 -1
- PyFunceble/dataset/inactive/__init__.py +1 -1
- PyFunceble/dataset/inactive/base.py +1 -1
- PyFunceble/dataset/inactive/csv.py +1 -1
- PyFunceble/dataset/inactive/sql.py +1 -1
- PyFunceble/dataset/ipv4_reputation.py +1 -1
- PyFunceble/dataset/public_suffix.py +1 -1
- PyFunceble/dataset/sql_base.py +4 -3
- PyFunceble/dataset/user_agent.py +1 -1
- PyFunceble/dataset/whois/__init__.py +1 -1
- PyFunceble/dataset/whois/base.py +1 -1
- PyFunceble/dataset/whois/csv.py +1 -1
- PyFunceble/dataset/whois/sql.py +1 -1
- PyFunceble/downloader/__init__.py +1 -1
- PyFunceble/downloader/base.py +1 -1
- PyFunceble/downloader/exceptions.py +1 -1
- PyFunceble/downloader/iana.py +1 -1
- PyFunceble/downloader/ipv4_reputation.py +1 -1
- PyFunceble/downloader/public_suffix.py +1 -1
- PyFunceble/downloader/user_agents.py +1 -1
- PyFunceble/exceptions.py +1 -1
- PyFunceble/facility.py +1 -1
- PyFunceble/factory.py +1 -1
- PyFunceble/helpers/__init__.py +1 -1
- PyFunceble/helpers/command.py +1 -1
- PyFunceble/helpers/dict.py +1 -1
- PyFunceble/helpers/directory.py +1 -1
- PyFunceble/helpers/download.py +1 -1
- PyFunceble/helpers/environment_variable.py +1 -1
- PyFunceble/helpers/exceptions.py +1 -1
- PyFunceble/helpers/file.py +1 -1
- PyFunceble/helpers/hash.py +1 -1
- PyFunceble/helpers/list.py +1 -1
- PyFunceble/helpers/merge.py +1 -1
- PyFunceble/helpers/regex.py +1 -1
- PyFunceble/logger.py +34 -11
- PyFunceble/query/__init__.py +1 -1
- PyFunceble/query/dns/__init__.py +1 -1
- PyFunceble/query/dns/nameserver.py +1 -1
- PyFunceble/query/dns/query_tool.py +1 -1
- PyFunceble/query/dns/resolver.py +1 -1
- PyFunceble/query/http_status_code.py +1 -1
- PyFunceble/query/netinfo/__init__.py +1 -1
- PyFunceble/query/netinfo/address.py +1 -1
- PyFunceble/query/netinfo/base.py +1 -1
- PyFunceble/query/netinfo/hostbyaddr.py +1 -1
- PyFunceble/query/platform.py +1 -1
- PyFunceble/query/record/__init__.py +1 -1
- PyFunceble/query/record/base.py +1 -1
- PyFunceble/query/record/dns.py +1 -1
- PyFunceble/query/record/whois.py +1 -1
- PyFunceble/query/requests/__init__.py +1 -1
- PyFunceble/query/requests/adapter/__init__.py +1 -1
- PyFunceble/query/requests/adapter/base.py +1 -1
- PyFunceble/query/requests/adapter/http.py +1 -1
- PyFunceble/query/requests/adapter/https.py +1 -1
- PyFunceble/query/requests/requester.py +1 -1
- PyFunceble/query/whois/__init__.py +1 -1
- PyFunceble/query/whois/converter/__init__.py +1 -1
- PyFunceble/query/whois/converter/base.py +1 -1
- PyFunceble/query/whois/converter/digit2digits.py +1 -1
- PyFunceble/query/whois/converter/expiration_date.py +1 -1
- PyFunceble/query/whois/converter/month2unified.py +1 -1
- PyFunceble/query/whois/converter/registrar.py +1 -1
- PyFunceble/query/whois/query_tool.py +1 -1
- PyFunceble/sessions.py +1 -1
- PyFunceble/storage.py +2 -2
- PyFunceble/storage_facility.py +1 -1
- PyFunceble/utils/__init__.py +1 -1
- PyFunceble/utils/platform.py +1 -1
- PyFunceble/utils/profile.py +1 -1
- PyFunceble/utils/version.py +1 -1
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a16.dist-info}/LICENSE +1 -1
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a16.dist-info}/METADATA +133 -112
- pyfunceble_dev-4.3.0a16.dist-info/RECORD +284 -0
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a16.dist-info}/WHEEL +1 -1
- PyFunceble_dev-4.3.0a15.dist-info/RECORD +0 -284
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a16.dist-info}/entry_points.txt +0 -0
- {PyFunceble_dev-4.3.0a15.dist-info → pyfunceble_dev-4.3.0a16.dist-info}/top_level.txt +0 -0
PyFunceble/cli/processes/base.py
CHANGED
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -50,451 +50,13 @@ License:
|
|
50
50
|
limitations under the License.
|
51
51
|
"""
|
52
52
|
|
53
|
-
import
|
54
|
-
import multiprocessing
|
55
|
-
import os
|
56
|
-
import queue
|
57
|
-
from typing import Any, List, Optional
|
53
|
+
# pylint: disable=import-error,no-name-in-module,no-member
|
58
54
|
|
55
|
+
import PyFunceble.ext.process_manager
|
59
56
|
import PyFunceble.facility
|
60
|
-
from PyFunceble.cli.continuous_integration.base import ContinuousIntegrationBase
|
61
|
-
from PyFunceble.cli.processes.workers.base import WorkerBase
|
62
57
|
|
63
58
|
|
64
|
-
class ProcessesManagerBase:
|
59
|
+
class ProcessesManagerBase(PyFunceble.ext.process_manager.ProcessManagerCore):
|
65
60
|
"""
|
66
61
|
Provides the base of all classes.
|
67
62
|
"""
|
68
|
-
|
69
|
-
CPU_COUNT = os.cpu_count()
|
70
|
-
|
71
|
-
if CPU_COUNT > 2:
|
72
|
-
STD_MAX_WORKER: int = CPU_COUNT - 2
|
73
|
-
else:
|
74
|
-
STD_MAX_WORKER: int = 1
|
75
|
-
|
76
|
-
WORKER_OBJ: Optional[WorkerBase] = None
|
77
|
-
|
78
|
-
input_datasets: Optional[List] = []
|
79
|
-
"""
|
80
|
-
Use this variable if you want to differ the addition in the input queue.
|
81
|
-
"""
|
82
|
-
|
83
|
-
output_datasets: Optional[List] = []
|
84
|
-
"""
|
85
|
-
Use this variable if you want to differ the addition in the output queue.
|
86
|
-
"""
|
87
|
-
|
88
|
-
input_queue: Optional[queue.Queue] = None
|
89
|
-
"""
|
90
|
-
The input queue. Dataset will be given through this.
|
91
|
-
"""
|
92
|
-
|
93
|
-
output_queue: Optional[List[queue.Queue]] = None
|
94
|
-
"""
|
95
|
-
The output queue. This is where the result of a worker will be put.
|
96
|
-
"""
|
97
|
-
|
98
|
-
daemon: Optional[bool] = None
|
99
|
-
|
100
|
-
manager: Optional[multiprocessing.Manager] = None
|
101
|
-
|
102
|
-
global_exit_event: Optional[multiprocessing.Event] = None
|
103
|
-
continuous_integration: Optional[ContinuousIntegrationBase] = None
|
104
|
-
|
105
|
-
_created_workers: Optional[List[WorkerBase]] = None
|
106
|
-
_running_workers: Optional[List[WorkerBase]] = None
|
107
|
-
_output_workers_count: Optional[int] = None
|
108
|
-
|
109
|
-
_max_worker: Optional[int] = None
|
110
|
-
|
111
|
-
def __init__(
|
112
|
-
self,
|
113
|
-
manager: Optional[multiprocessing.Manager] = None,
|
114
|
-
max_worker: Optional[int] = None,
|
115
|
-
*,
|
116
|
-
continuous_integration: Optional[ContinuousIntegrationBase] = None,
|
117
|
-
input_queue: Optional[queue.Queue] = None,
|
118
|
-
output_queue: Optional[queue.Queue] = None,
|
119
|
-
daemon: bool = False,
|
120
|
-
generate_input_queue: bool = True,
|
121
|
-
generate_output_queue: bool = True,
|
122
|
-
output_queue_num: int = 1,
|
123
|
-
output_workers_count: Optional[int] = None,
|
124
|
-
) -> None:
|
125
|
-
if manager is not None:
|
126
|
-
self.manager = manager
|
127
|
-
else:
|
128
|
-
self.manager = multiprocessing.Manager()
|
129
|
-
|
130
|
-
if input_queue is None:
|
131
|
-
if generate_input_queue:
|
132
|
-
self.input_queue = self.manager.Queue()
|
133
|
-
else:
|
134
|
-
self.input_queue = None
|
135
|
-
else:
|
136
|
-
self.input_queue = input_queue
|
137
|
-
|
138
|
-
if output_queue is None:
|
139
|
-
if generate_output_queue:
|
140
|
-
self.output_queue = [
|
141
|
-
self.manager.Queue() for _ in range(output_queue_num)
|
142
|
-
]
|
143
|
-
else:
|
144
|
-
self.output_queue = None
|
145
|
-
else:
|
146
|
-
if not isinstance(output_queue, list):
|
147
|
-
self.output_queue = [output_queue]
|
148
|
-
else:
|
149
|
-
self.output_queue = output_queue
|
150
|
-
|
151
|
-
if max_worker is not None:
|
152
|
-
self.max_worker = max_worker
|
153
|
-
else:
|
154
|
-
self.max_worker = self.STD_MAX_WORKER
|
155
|
-
|
156
|
-
if continuous_integration is not None:
|
157
|
-
self.continuous_integration = continuous_integration
|
158
|
-
|
159
|
-
self.daemon = daemon
|
160
|
-
|
161
|
-
self.global_exit_event = multiprocessing.Event()
|
162
|
-
|
163
|
-
self._running_workers = []
|
164
|
-
self._created_workers = []
|
165
|
-
|
166
|
-
if output_workers_count is None:
|
167
|
-
self._output_workers_count = 1
|
168
|
-
else:
|
169
|
-
self._output_workers_count = int(output_workers_count)
|
170
|
-
|
171
|
-
def ensure_worker_obj_is_given(func): # pylint: disable=no-self-argument
|
172
|
-
"""
|
173
|
-
Ensures that the worker is properly declared before launching the
|
174
|
-
decorated method.
|
175
|
-
"""
|
176
|
-
|
177
|
-
@functools.wraps(func)
|
178
|
-
def wrapper(self, *args, **kwargs):
|
179
|
-
if self.WORKER_OBJ is None:
|
180
|
-
raise TypeError(f"<self.WORKER_OBJ> should not be {None}!")
|
181
|
-
|
182
|
-
return func(self, *args, **kwargs) # pylint: disable=not-callable
|
183
|
-
|
184
|
-
return wrapper
|
185
|
-
|
186
|
-
def create_workers_if_missing(func): # pylint: disable=no-self-argument
|
187
|
-
"""
|
188
|
-
Creates the workers if they are missing before launching the decorated
|
189
|
-
method.
|
190
|
-
"""
|
191
|
-
|
192
|
-
@functools.wraps(func)
|
193
|
-
def wrapper(self, *args, **kwargs):
|
194
|
-
# pylint: disable=protected-access
|
195
|
-
if not self._created_workers:
|
196
|
-
self.create()
|
197
|
-
|
198
|
-
return func(self, *args, **kwargs) # pylint: disable=not-callable
|
199
|
-
|
200
|
-
return wrapper
|
201
|
-
|
202
|
-
def ignore_if_running(func): # pylint: disable=no-self-argument
|
203
|
-
"""
|
204
|
-
Ignore the launching of the decorated method if the workers are
|
205
|
-
running.
|
206
|
-
"""
|
207
|
-
|
208
|
-
@functools.wraps(func)
|
209
|
-
def wrapper(self, *args, **kwargs):
|
210
|
-
if not self.is_running():
|
211
|
-
return func(self, *args, **kwargs) # pylint: disable=not-callable
|
212
|
-
|
213
|
-
return self
|
214
|
-
|
215
|
-
return wrapper
|
216
|
-
|
217
|
-
@property
|
218
|
-
def max_worker(self) -> Optional[int]:
|
219
|
-
"""
|
220
|
-
Provides the number of maximum worker we are allowed to generate.
|
221
|
-
"""
|
222
|
-
|
223
|
-
return self._max_worker
|
224
|
-
|
225
|
-
@max_worker.setter
|
226
|
-
def max_worker(self, value: int) -> None:
|
227
|
-
"""
|
228
|
-
Sets the number of maximum worker we are authorized to generate.
|
229
|
-
|
230
|
-
:param value:
|
231
|
-
The value to set.
|
232
|
-
|
233
|
-
:raise TypeError:
|
234
|
-
When the given :code:`value` is not a :py:class:`int`.
|
235
|
-
:raise ValueError:
|
236
|
-
When the given :code:`value` is less than :code:`1`.
|
237
|
-
"""
|
238
|
-
|
239
|
-
if not isinstance(value, int):
|
240
|
-
raise TypeError(f"<value> should be {int}, {type(value)} given.")
|
241
|
-
|
242
|
-
if value < 1:
|
243
|
-
raise ValueError("<value> should be greater or equal to one.")
|
244
|
-
|
245
|
-
self._max_worker = value
|
246
|
-
|
247
|
-
def set_max_worker(self, value: int) -> "ProcessesManagerBase":
|
248
|
-
"""
|
249
|
-
Sets the number of maximum worker we are authorized to generate.
|
250
|
-
|
251
|
-
:param value:
|
252
|
-
The value to set.
|
253
|
-
"""
|
254
|
-
|
255
|
-
self.max_worker = value
|
256
|
-
|
257
|
-
return self
|
258
|
-
|
259
|
-
def is_running(self) -> bool:
|
260
|
-
"""
|
261
|
-
Checks if a worker is running.
|
262
|
-
"""
|
263
|
-
|
264
|
-
if not self._running_workers:
|
265
|
-
return False
|
266
|
-
|
267
|
-
for worker in self._running_workers:
|
268
|
-
if worker.is_alive():
|
269
|
-
return True
|
270
|
-
|
271
|
-
return False
|
272
|
-
|
273
|
-
def send_stop_signal(
|
274
|
-
self, *, worker_name: Optional[str] = None
|
275
|
-
) -> "ProcessesManagerBase":
|
276
|
-
"""
|
277
|
-
Sends a stop message to the input queue.
|
278
|
-
"""
|
279
|
-
|
280
|
-
self.add_to_all_input_queues(
|
281
|
-
"stop", worker_name=worker_name, include_destination=True
|
282
|
-
)
|
283
|
-
|
284
|
-
def terminate(self) -> "ProcessesManagerBase":
|
285
|
-
"""
|
286
|
-
Terminates all workers and send a stop message to the declared output
|
287
|
-
queues - which are implicitly dependend of this process "pool".
|
288
|
-
"""
|
289
|
-
|
290
|
-
if self._running_workers:
|
291
|
-
workers = self._running_workers
|
292
|
-
else:
|
293
|
-
workers = self._created_workers
|
294
|
-
|
295
|
-
if workers[0].global_exit_event:
|
296
|
-
workers[0].global_exit_event.set()
|
297
|
-
|
298
|
-
for worker in workers:
|
299
|
-
worker.terminate()
|
300
|
-
worker.join()
|
301
|
-
|
302
|
-
# When all worker of the current process are down or finished, send the
|
303
|
-
# stop message to the depending workers.
|
304
|
-
|
305
|
-
self.add_to_all_output_queues("stop")
|
306
|
-
|
307
|
-
def wait(self) -> "ProcessesManagerBase":
|
308
|
-
"""
|
309
|
-
Wait until all workers are done.
|
310
|
-
"""
|
311
|
-
|
312
|
-
for worker in self._running_workers:
|
313
|
-
PyFunceble.facility.Logger.info(
|
314
|
-
"Waiting for %r to finish.",
|
315
|
-
worker.name,
|
316
|
-
)
|
317
|
-
worker.join()
|
318
|
-
|
319
|
-
self._running_workers.remove(worker)
|
320
|
-
PyFunceble.facility.Logger.info(
|
321
|
-
"Still running: %r.",
|
322
|
-
self._running_workers,
|
323
|
-
)
|
324
|
-
|
325
|
-
for worker in self._created_workers:
|
326
|
-
if worker.exception:
|
327
|
-
worker_error, _ = worker.exception
|
328
|
-
|
329
|
-
self.terminate()
|
330
|
-
raise worker_error
|
331
|
-
|
332
|
-
self.terminate()
|
333
|
-
|
334
|
-
@create_workers_if_missing
|
335
|
-
def add_to_all_input_queues(
|
336
|
-
self,
|
337
|
-
data: Any,
|
338
|
-
*,
|
339
|
-
worker_name: Optional[str] = None,
|
340
|
-
include_destination: bool = False,
|
341
|
-
) -> "ProcessesManagerBase":
|
342
|
-
"""
|
343
|
-
Adds the given data to the input queues.
|
344
|
-
|
345
|
-
:param data:
|
346
|
-
The data to add into the queue.
|
347
|
-
|
348
|
-
:param include_destination:
|
349
|
-
Authorizes the addition of the destination into the message.
|
350
|
-
"""
|
351
|
-
|
352
|
-
if self.is_running():
|
353
|
-
workers = self._running_workers
|
354
|
-
else:
|
355
|
-
workers = self._created_workers
|
356
|
-
|
357
|
-
for worker in workers:
|
358
|
-
if include_destination:
|
359
|
-
worker.add_to_input_queue(
|
360
|
-
data, worker_name=worker_name, destination_worker=worker.name
|
361
|
-
)
|
362
|
-
else:
|
363
|
-
worker.add_to_input_queue(data, worker_name=worker_name)
|
364
|
-
|
365
|
-
PyFunceble.facility.Logger.debug("Added to all (input) queues: %r", data)
|
366
|
-
|
367
|
-
@create_workers_if_missing
|
368
|
-
def add_to_all_output_queues(
|
369
|
-
self,
|
370
|
-
data: Any,
|
371
|
-
*,
|
372
|
-
worker_name: Optional[str] = None,
|
373
|
-
) -> "ProcessesManagerBase":
|
374
|
-
"""
|
375
|
-
Adds the given data to the output queues.
|
376
|
-
|
377
|
-
:param data:
|
378
|
-
The data to add into the queue.
|
379
|
-
:param worker_name:
|
380
|
-
The name of the worker that is sending the message.
|
381
|
-
"""
|
382
|
-
|
383
|
-
for _ in range(self._output_workers_count):
|
384
|
-
self.add_to_output_queue(data, worker_name=worker_name)
|
385
|
-
|
386
|
-
PyFunceble.facility.Logger.debug("Added to all (output) queues: %r", data)
|
387
|
-
|
388
|
-
return self
|
389
|
-
|
390
|
-
@create_workers_if_missing
|
391
|
-
def add_to_input_queue(
|
392
|
-
self, data: Any, *, worker_name: Optional[str] = None
|
393
|
-
) -> "ProcessesManagerBase":
|
394
|
-
"""
|
395
|
-
Adds the given data to the current queue.
|
396
|
-
|
397
|
-
:param data:
|
398
|
-
The data to add into the queue.
|
399
|
-
"""
|
400
|
-
|
401
|
-
if self.is_running():
|
402
|
-
self._running_workers[0].add_to_input_queue(data, worker_name=worker_name)
|
403
|
-
else:
|
404
|
-
self._created_workers[0].add_to_input_queue(data, worker_name=worker_name)
|
405
|
-
|
406
|
-
PyFunceble.facility.Logger.debug("Added to the (main) queue: %r", data)
|
407
|
-
|
408
|
-
@create_workers_if_missing
|
409
|
-
def add_to_output_queue(
|
410
|
-
self, data: Any, *, worker_name: Optional[str] = None
|
411
|
-
) -> "ProcessesManagerBase":
|
412
|
-
"""
|
413
|
-
Adds the given data to the output queue.
|
414
|
-
|
415
|
-
:param data:
|
416
|
-
The data to add into the queue.
|
417
|
-
"""
|
418
|
-
|
419
|
-
if self.is_running():
|
420
|
-
self._running_workers[0].add_to_output_queue(data, worker_name=worker_name)
|
421
|
-
else:
|
422
|
-
self._created_workers[0].add_to_output_queue(data, worker_name=worker_name)
|
423
|
-
|
424
|
-
PyFunceble.facility.Logger.debug("Added to the (output) queue: %r", data)
|
425
|
-
|
426
|
-
return self
|
427
|
-
|
428
|
-
def create(self) -> "ProcessesManagerBase":
|
429
|
-
"""
|
430
|
-
Creates the defined amount of worker.
|
431
|
-
"""
|
432
|
-
|
433
|
-
def share_concurrent_worker_names() -> None:
|
434
|
-
"""
|
435
|
-
Share the name of all concurrent worker to all workers.
|
436
|
-
"""
|
437
|
-
|
438
|
-
concurrent_names = [x.name for x in self._created_workers]
|
439
|
-
|
440
|
-
for worker in self._created_workers:
|
441
|
-
worker.concurrent_worker_names = list(concurrent_names)
|
442
|
-
worker.concurrent_worker_names.remove(worker.name)
|
443
|
-
|
444
|
-
for i in range(self.max_worker):
|
445
|
-
worker = self.WORKER_OBJ( # pylint: disable=not-callable
|
446
|
-
self.input_queue,
|
447
|
-
self.output_queue,
|
448
|
-
self.global_exit_event,
|
449
|
-
name=f"{self.WORKER_OBJ.STD_NAME}_{i + 1}",
|
450
|
-
daemon=self.daemon,
|
451
|
-
continuous_integration=self.continuous_integration,
|
452
|
-
configuration=PyFunceble.storage.CONFIGURATION.to_dict(),
|
453
|
-
)
|
454
|
-
|
455
|
-
self._created_workers.append(worker)
|
456
|
-
|
457
|
-
share_concurrent_worker_names()
|
458
|
-
|
459
|
-
PyFunceble.facility.Logger.info(
|
460
|
-
"Created %r workers of %r. Details:\n%r",
|
461
|
-
len(self._created_workers),
|
462
|
-
self.WORKER_OBJ,
|
463
|
-
self._created_workers,
|
464
|
-
)
|
465
|
-
|
466
|
-
return self
|
467
|
-
|
468
|
-
@ensure_worker_obj_is_given
|
469
|
-
@create_workers_if_missing
|
470
|
-
@ignore_if_running
|
471
|
-
def start(self) -> "ProcessesManagerBase":
|
472
|
-
"""
|
473
|
-
Starts all - previously - created workers.
|
474
|
-
"""
|
475
|
-
|
476
|
-
for worker in self._created_workers:
|
477
|
-
try:
|
478
|
-
worker.start()
|
479
|
-
except AssertionError:
|
480
|
-
# Example: cannot start a process twice
|
481
|
-
pass
|
482
|
-
|
483
|
-
self._running_workers.append(worker)
|
484
|
-
|
485
|
-
if self.input_datasets:
|
486
|
-
while self.input_datasets:
|
487
|
-
self.add_to_input_queue(self.input_datasets.pop())
|
488
|
-
|
489
|
-
if self.output_datasets:
|
490
|
-
while self.output_datasets:
|
491
|
-
self.add_to_output_queue(self.output_datasets.pop())
|
492
|
-
|
493
|
-
PyFunceble.facility.Logger.info(
|
494
|
-
"Started %r workers of %r. Details:\n%r",
|
495
|
-
len(self._running_workers),
|
496
|
-
self.WORKER_OBJ,
|
497
|
-
self._running_workers,
|
498
|
-
)
|
499
|
-
|
500
|
-
return self
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -66,4 +66,5 @@ class ChancyProducerProcessesManager(ProcessesManagerBase):
|
|
66
66
|
if you believe in your own luck.
|
67
67
|
"""
|
68
68
|
|
69
|
-
|
69
|
+
STD_NAME: str = "pyfunceble_chancy_producer_worker"
|
70
|
+
WORKER_CLASS: ChancyProducerWorker = ChancyProducerWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -66,4 +66,5 @@ class ChancyTesterProcessesManager(ProcessesManagerBase):
|
|
66
66
|
if you believe in your own luck.
|
67
67
|
"""
|
68
68
|
|
69
|
-
|
69
|
+
STD_NAME: str = "pyfunceble_chancy_tester_worker"
|
70
|
+
WORKER_CLASS: ChancyTesterWorker = ChancyTesterWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -59,4 +59,5 @@ class DirFileSorterProcessesManager(ProcessesManagerBase):
|
|
59
59
|
Provides the directory files sorter manager.
|
60
60
|
"""
|
61
61
|
|
62
|
-
|
62
|
+
STD_NAME: str = "pyfunceble_dir_files_sorter_worker"
|
63
|
+
WORKER_CLASS: DireFileSorterWorker = DireFileSorterWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -59,4 +59,5 @@ class FileSorterProcessesManager(ProcessesManagerBase):
|
|
59
59
|
Provides the file sorter manager.
|
60
60
|
"""
|
61
61
|
|
62
|
-
|
62
|
+
STD_NAME: str = "pyfunceble_file_sorter_worker"
|
63
|
+
WORKER_CLASS: FileSorterWorker = FileSorterWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -89,7 +89,8 @@ class MigratorProcessesManager(ProcessesManagerBase):
|
|
89
89
|
Provides the migrator manager.
|
90
90
|
"""
|
91
91
|
|
92
|
-
|
92
|
+
STD_NAME: str = "pyfunceble_migrator_worker"
|
93
|
+
WORKER_CLASS: MigratorWorker = MigratorWorker
|
93
94
|
|
94
95
|
@staticmethod
|
95
96
|
def json2csv_inactive_target(
|
@@ -430,27 +431,37 @@ class MigratorProcessesManager(ProcessesManagerBase):
|
|
430
431
|
"Stopped csv_file_add_registrar_column_target. File does not exist."
|
431
432
|
)
|
432
433
|
|
433
|
-
def
|
434
|
+
def spawn_workers(self, *, start: bool = False) -> "ProcessesManagerBase":
|
435
|
+
"""
|
436
|
+
Spawn the necessary workers.
|
437
|
+
|
438
|
+
:param bool start:
|
439
|
+
Whether we should start the workers or not.
|
440
|
+
"""
|
441
|
+
|
434
442
|
for method in dir(self):
|
435
443
|
if not method.endswith("_target"):
|
436
444
|
continue
|
437
445
|
|
438
|
-
worker =
|
439
|
-
|
440
|
-
name=f"pyfunceble_{method}",
|
441
|
-
daemon=True,
|
442
|
-
continuous_integration=self.continuous_integration,
|
443
|
-
)
|
444
|
-
|
446
|
+
worker = self.spawn_worker(start=False, daemon=True, force=True)
|
447
|
+
worker.name = f"pyfunceble_{method}"
|
445
448
|
worker.target = getattr(self, method)
|
446
449
|
|
447
|
-
|
450
|
+
if start:
|
451
|
+
worker.start()
|
452
|
+
self.running_workers.append(worker)
|
453
|
+
|
448
454
|
PyFunceble.facility.Logger.info("Created worker for %r", method)
|
449
455
|
|
450
|
-
@ProcessesManagerBase.
|
451
|
-
@ProcessesManagerBase.
|
456
|
+
@ProcessesManagerBase.ensure_worker_class_is_set
|
457
|
+
@ProcessesManagerBase.ensure_worker_spawned
|
458
|
+
@ProcessesManagerBase.ignore_if_running
|
452
459
|
def start(self) -> "ProcessesManagerBase":
|
460
|
+
"""
|
461
|
+
Starts the migration process.
|
462
|
+
"""
|
463
|
+
|
453
464
|
# We start the migration (as a standalone)
|
454
|
-
Alembic(self.
|
465
|
+
Alembic(self.created_workers[0].db_session).upgrade()
|
455
466
|
|
456
467
|
return super().start()
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -59,4 +59,5 @@ class MinerProcessesManager(ProcessesManagerBase):
|
|
59
59
|
Provides the miner manager.
|
60
60
|
"""
|
61
61
|
|
62
|
-
|
62
|
+
STD_NAME: str = "pyfunceble_miner_worker"
|
63
|
+
WORKER_CLASS: MinerWorker = MinerWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -59,4 +59,5 @@ class ProducerProcessesManager(ProcessesManagerBase):
|
|
59
59
|
Provides the producer manager.
|
60
60
|
"""
|
61
61
|
|
62
|
-
|
62
|
+
STD_NAME: str = "pyfunceble_producer_worker"
|
63
|
+
WORKER_CLASS: ProducerWorker = ProducerWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|
@@ -59,4 +59,5 @@ class TesterProcessesManager(ProcessesManagerBase):
|
|
59
59
|
Provides the tester manager.
|
60
60
|
"""
|
61
61
|
|
62
|
-
|
62
|
+
STD_NAME: str = "pyfunceble_tester_worker"
|
63
|
+
WORKER_CLASS: TesterWorker = TesterWorker
|
@@ -35,7 +35,7 @@ License:
|
|
35
35
|
::
|
36
36
|
|
37
37
|
|
38
|
-
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 Nissar Chababy
|
38
|
+
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025 Nissar Chababy
|
39
39
|
|
40
40
|
Licensed under the Apache License, Version 2.0 (the "License");
|
41
41
|
you may not use this file except in compliance with the License.
|