exonware-xwsystem 0.1.0.1__py3-none-any.whl → 0.1.0.4__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.
- exonware/__init__.py +2 -1
- exonware/conf.py +2 -2
- exonware/xwsystem/__init__.py +115 -43
- exonware/xwsystem/base.py +30 -0
- exonware/xwsystem/caching/__init__.py +39 -13
- exonware/xwsystem/caching/base.py +24 -6
- exonware/xwsystem/caching/bloom_cache.py +2 -2
- exonware/xwsystem/caching/cache_manager.py +2 -1
- exonware/xwsystem/caching/conditional.py +2 -2
- exonware/xwsystem/caching/contracts.py +85 -139
- exonware/xwsystem/caching/decorators.py +6 -19
- exonware/xwsystem/caching/defs.py +2 -1
- exonware/xwsystem/caching/disk_cache.py +2 -1
- exonware/xwsystem/caching/distributed.py +2 -1
- exonware/xwsystem/caching/errors.py +2 -1
- exonware/xwsystem/caching/events.py +110 -27
- exonware/xwsystem/caching/eviction_strategies.py +2 -2
- exonware/xwsystem/caching/external_caching_python.py +701 -0
- exonware/xwsystem/caching/facade.py +253 -0
- exonware/xwsystem/caching/factory.py +300 -0
- exonware/xwsystem/caching/fluent.py +14 -12
- exonware/xwsystem/caching/integrity.py +21 -6
- exonware/xwsystem/caching/lfu_cache.py +2 -1
- exonware/xwsystem/caching/lfu_optimized.py +18 -6
- exonware/xwsystem/caching/lru_cache.py +7 -4
- exonware/xwsystem/caching/memory_bounded.py +2 -2
- exonware/xwsystem/caching/metrics_exporter.py +2 -2
- exonware/xwsystem/caching/observable_cache.py +2 -2
- exonware/xwsystem/caching/pluggable_cache.py +2 -2
- exonware/xwsystem/caching/rate_limiter.py +2 -2
- exonware/xwsystem/caching/read_through.py +2 -2
- exonware/xwsystem/caching/secure_cache.py +81 -28
- exonware/xwsystem/caching/serializable.py +9 -7
- exonware/xwsystem/caching/stats.py +2 -2
- exonware/xwsystem/caching/tagging.py +2 -2
- exonware/xwsystem/caching/ttl_cache.py +4 -3
- exonware/xwsystem/caching/two_tier_cache.py +6 -3
- exonware/xwsystem/caching/utils.py +30 -12
- exonware/xwsystem/caching/validation.py +2 -2
- exonware/xwsystem/caching/warming.py +6 -3
- exonware/xwsystem/caching/write_behind.py +15 -6
- exonware/xwsystem/config/__init__.py +11 -17
- exonware/xwsystem/config/base.py +5 -5
- exonware/xwsystem/config/contracts.py +93 -153
- exonware/xwsystem/config/defaults.py +3 -2
- exonware/xwsystem/config/defs.py +3 -2
- exonware/xwsystem/config/errors.py +2 -5
- exonware/xwsystem/config/logging.py +12 -8
- exonware/xwsystem/config/logging_setup.py +3 -2
- exonware/xwsystem/config/performance.py +1 -46
- exonware/xwsystem/config/performance_modes.py +9 -8
- exonware/xwsystem/config/version_manager.py +1 -0
- exonware/xwsystem/config.py +27 -0
- exonware/xwsystem/console/__init__.py +53 -0
- exonware/xwsystem/console/base.py +133 -0
- exonware/xwsystem/console/cli/__init__.py +61 -0
- exonware/xwsystem/{cli → console/cli}/args.py +27 -24
- exonware/xwsystem/{cli → console/cli}/base.py +18 -87
- exonware/xwsystem/{cli → console/cli}/colors.py +15 -13
- exonware/xwsystem/console/cli/console.py +98 -0
- exonware/xwsystem/{cli → console/cli}/contracts.py +51 -69
- exonware/xwsystem/console/cli/defs.py +87 -0
- exonware/xwsystem/console/cli/encoding.py +69 -0
- exonware/xwsystem/{cli → console/cli}/errors.py +8 -3
- exonware/xwsystem/console/cli/event_logger.py +166 -0
- exonware/xwsystem/{cli → console/cli}/progress.py +25 -21
- exonware/xwsystem/{cli → console/cli}/prompts.py +3 -2
- exonware/xwsystem/{cli → console/cli}/tables.py +27 -24
- exonware/xwsystem/console/contracts.py +113 -0
- exonware/xwsystem/console/defs.py +154 -0
- exonware/xwsystem/console/errors.py +34 -0
- exonware/xwsystem/console/event_logger.py +385 -0
- exonware/xwsystem/console/writer.py +132 -0
- exonware/xwsystem/contracts.py +28 -0
- exonware/xwsystem/data_structures/__init__.py +23 -0
- exonware/xwsystem/data_structures/trie.py +34 -0
- exonware/xwsystem/data_structures/union_find.py +144 -0
- exonware/xwsystem/defs.py +17 -0
- exonware/xwsystem/errors.py +23 -0
- exonware/xwsystem/facade.py +62 -0
- exonware/xwsystem/http_client/__init__.py +22 -1
- exonware/xwsystem/http_client/advanced_client.py +8 -5
- exonware/xwsystem/http_client/base.py +3 -2
- exonware/xwsystem/http_client/client.py +7 -4
- exonware/xwsystem/http_client/contracts.py +42 -56
- exonware/xwsystem/http_client/defs.py +2 -1
- exonware/xwsystem/http_client/errors.py +2 -1
- exonware/xwsystem/http_client/facade.py +156 -0
- exonware/xwsystem/io/__init__.py +22 -3
- exonware/xwsystem/io/archive/__init__.py +8 -2
- exonware/xwsystem/io/archive/archive.py +1 -1
- exonware/xwsystem/io/archive/archive_files.py +4 -7
- exonware/xwsystem/io/archive/archivers.py +120 -10
- exonware/xwsystem/io/archive/base.py +4 -5
- exonware/xwsystem/io/archive/codec_integration.py +1 -2
- exonware/xwsystem/io/archive/compression.py +1 -2
- exonware/xwsystem/io/archive/facade.py +263 -0
- exonware/xwsystem/io/archive/formats/__init__.py +2 -3
- exonware/xwsystem/io/archive/formats/brotli_format.py +20 -7
- exonware/xwsystem/io/archive/formats/lz4_format.py +20 -7
- exonware/xwsystem/io/archive/formats/rar.py +11 -5
- exonware/xwsystem/io/archive/formats/sevenzip.py +12 -6
- exonware/xwsystem/io/archive/formats/squashfs_format.py +1 -2
- exonware/xwsystem/io/archive/formats/tar.py +52 -7
- exonware/xwsystem/io/archive/formats/wim_format.py +11 -5
- exonware/xwsystem/io/archive/formats/zip.py +1 -2
- exonware/xwsystem/io/archive/formats/zpaq_format.py +1 -2
- exonware/xwsystem/io/archive/formats/zstandard.py +20 -7
- exonware/xwsystem/io/base.py +119 -115
- exonware/xwsystem/io/codec/__init__.py +4 -2
- exonware/xwsystem/io/codec/base.py +19 -13
- exonware/xwsystem/io/codec/contracts.py +59 -2
- exonware/xwsystem/io/codec/registry.py +67 -21
- exonware/xwsystem/io/common/__init__.py +1 -1
- exonware/xwsystem/io/common/atomic.py +29 -16
- exonware/xwsystem/io/common/base.py +11 -10
- exonware/xwsystem/io/common/lock.py +6 -5
- exonware/xwsystem/io/common/path_manager.py +2 -1
- exonware/xwsystem/io/common/watcher.py +1 -2
- exonware/xwsystem/io/contracts.py +301 -433
- exonware/xwsystem/io/contracts_1.py +1180 -0
- exonware/xwsystem/io/data_operations.py +19 -20
- exonware/xwsystem/io/defs.py +4 -3
- exonware/xwsystem/io/errors.py +3 -2
- exonware/xwsystem/io/facade.py +87 -61
- exonware/xwsystem/io/file/__init__.py +1 -1
- exonware/xwsystem/io/file/base.py +8 -9
- exonware/xwsystem/io/file/conversion.py +2 -3
- exonware/xwsystem/io/file/file.py +61 -18
- exonware/xwsystem/io/file/paged_source.py +8 -8
- exonware/xwsystem/io/file/paging/__init__.py +1 -2
- exonware/xwsystem/io/file/paging/byte_paging.py +4 -5
- exonware/xwsystem/io/file/paging/line_paging.py +2 -3
- exonware/xwsystem/io/file/paging/record_paging.py +2 -3
- exonware/xwsystem/io/file/paging/registry.py +1 -2
- exonware/xwsystem/io/file/source.py +13 -17
- exonware/xwsystem/io/filesystem/__init__.py +1 -1
- exonware/xwsystem/io/filesystem/base.py +1 -2
- exonware/xwsystem/io/filesystem/local.py +3 -4
- exonware/xwsystem/io/folder/__init__.py +1 -1
- exonware/xwsystem/io/folder/base.py +1 -2
- exonware/xwsystem/io/folder/folder.py +16 -7
- exonware/xwsystem/io/indexing/__init__.py +14 -0
- exonware/xwsystem/io/indexing/facade.py +443 -0
- exonware/xwsystem/io/path_parser.py +98 -0
- exonware/xwsystem/io/serialization/__init__.py +21 -3
- exonware/xwsystem/io/serialization/auto_serializer.py +146 -20
- exonware/xwsystem/io/serialization/base.py +84 -34
- exonware/xwsystem/io/serialization/contracts.py +50 -73
- exonware/xwsystem/io/serialization/defs.py +2 -1
- exonware/xwsystem/io/serialization/errors.py +2 -1
- exonware/xwsystem/io/serialization/flyweight.py +154 -7
- exonware/xwsystem/io/serialization/format_detector.py +15 -14
- exonware/xwsystem/io/serialization/formats/__init__.py +8 -5
- exonware/xwsystem/io/serialization/formats/binary/bson.py +15 -6
- exonware/xwsystem/io/serialization/formats/binary/cbor.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/marshal.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/msgpack.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/pickle.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/plistlib.py +5 -5
- exonware/xwsystem/io/serialization/formats/database/dbm.py +7 -7
- exonware/xwsystem/io/serialization/formats/database/shelve.py +7 -7
- exonware/xwsystem/io/serialization/formats/database/sqlite3.py +7 -7
- exonware/xwsystem/io/serialization/formats/tabular/__init__.py +27 -0
- exonware/xwsystem/io/serialization/formats/tabular/base.py +89 -0
- exonware/xwsystem/io/serialization/formats/tabular/csv.py +319 -0
- exonware/xwsystem/io/serialization/formats/tabular/df.py +249 -0
- exonware/xwsystem/io/serialization/formats/tabular/excel.py +291 -0
- exonware/xwsystem/io/serialization/formats/tabular/googlesheets.py +374 -0
- exonware/xwsystem/io/serialization/formats/text/__init__.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/append_only_log.py +5 -7
- exonware/xwsystem/io/serialization/formats/text/configparser.py +5 -5
- exonware/xwsystem/io/serialization/formats/text/csv.py +7 -5
- exonware/xwsystem/io/serialization/formats/text/formdata.py +5 -5
- exonware/xwsystem/io/serialization/formats/text/json.py +27 -18
- exonware/xwsystem/io/serialization/formats/text/json5.py +8 -4
- exonware/xwsystem/io/serialization/formats/text/jsonlines.py +18 -14
- exonware/xwsystem/io/serialization/formats/text/multipart.py +5 -5
- exonware/xwsystem/io/serialization/formats/text/toml.py +8 -6
- exonware/xwsystem/io/serialization/formats/text/xml.py +25 -20
- exonware/xwsystem/io/serialization/formats/text/yaml.py +8 -6
- exonware/xwsystem/io/serialization/parsers/__init__.py +3 -2
- exonware/xwsystem/io/serialization/parsers/base.py +6 -5
- exonware/xwsystem/io/serialization/parsers/hybrid_parser.py +7 -6
- exonware/xwsystem/io/serialization/parsers/msgspec_parser.py +10 -7
- exonware/xwsystem/io/serialization/parsers/orjson_direct_parser.py +7 -6
- exonware/xwsystem/io/serialization/parsers/orjson_parser.py +11 -8
- exonware/xwsystem/io/serialization/parsers/pysimdjson_parser.py +13 -9
- exonware/xwsystem/io/serialization/parsers/rapidjson_parser.py +10 -7
- exonware/xwsystem/io/serialization/parsers/registry.py +11 -10
- exonware/xwsystem/io/serialization/parsers/standard.py +7 -6
- exonware/xwsystem/io/serialization/parsers/ujson_parser.py +10 -7
- exonware/xwsystem/io/serialization/registry.py +4 -4
- exonware/xwsystem/io/serialization/serializer.py +168 -79
- exonware/xwsystem/io/serialization/universal_options.py +367 -0
- exonware/xwsystem/io/serialization/utils/__init__.py +1 -2
- exonware/xwsystem/io/serialization/utils/path_ops.py +5 -6
- exonware/xwsystem/io/source_reader.py +223 -0
- exonware/xwsystem/io/stream/__init__.py +1 -1
- exonware/xwsystem/io/stream/async_operations.py +61 -14
- exonware/xwsystem/io/stream/base.py +1 -2
- exonware/xwsystem/io/stream/codec_io.py +6 -7
- exonware/xwsystem/ipc/__init__.py +1 -0
- exonware/xwsystem/ipc/async_fabric.py +4 -4
- exonware/xwsystem/ipc/base.py +6 -5
- exonware/xwsystem/ipc/contracts.py +41 -66
- exonware/xwsystem/ipc/defs.py +2 -1
- exonware/xwsystem/ipc/errors.py +2 -1
- exonware/xwsystem/ipc/message_queue.py +5 -2
- exonware/xwsystem/ipc/pipes.py +70 -34
- exonware/xwsystem/ipc/process_manager.py +7 -5
- exonware/xwsystem/ipc/process_pool.py +6 -5
- exonware/xwsystem/ipc/shared_memory.py +64 -11
- exonware/xwsystem/monitoring/__init__.py +7 -0
- exonware/xwsystem/monitoring/base.py +11 -8
- exonware/xwsystem/monitoring/contracts.py +86 -144
- exonware/xwsystem/monitoring/defs.py +2 -1
- exonware/xwsystem/monitoring/error_recovery.py +16 -3
- exonware/xwsystem/monitoring/errors.py +2 -1
- exonware/xwsystem/monitoring/facade.py +183 -0
- exonware/xwsystem/monitoring/memory_monitor.py +1 -0
- exonware/xwsystem/monitoring/metrics.py +1 -0
- exonware/xwsystem/monitoring/performance_manager_generic.py +7 -7
- exonware/xwsystem/monitoring/performance_monitor.py +1 -0
- exonware/xwsystem/monitoring/performance_validator.py +1 -0
- exonware/xwsystem/monitoring/system_monitor.py +6 -5
- exonware/xwsystem/monitoring/tracing.py +18 -16
- exonware/xwsystem/monitoring/tracker.py +2 -1
- exonware/xwsystem/operations/__init__.py +5 -50
- exonware/xwsystem/operations/base.py +3 -44
- exonware/xwsystem/operations/contracts.py +25 -15
- exonware/xwsystem/operations/defs.py +1 -1
- exonware/xwsystem/operations/diff.py +5 -4
- exonware/xwsystem/operations/errors.py +1 -1
- exonware/xwsystem/operations/merge.py +6 -4
- exonware/xwsystem/operations/patch.py +5 -4
- exonware/xwsystem/patterns/__init__.py +1 -0
- exonware/xwsystem/patterns/base.py +2 -1
- exonware/xwsystem/patterns/context_manager.py +2 -1
- exonware/xwsystem/patterns/contracts.py +215 -256
- exonware/xwsystem/patterns/defs.py +2 -1
- exonware/xwsystem/patterns/dynamic_facade.py +1 -0
- exonware/xwsystem/patterns/errors.py +2 -4
- exonware/xwsystem/patterns/handler_factory.py +2 -3
- exonware/xwsystem/patterns/import_registry.py +1 -0
- exonware/xwsystem/patterns/object_pool.py +1 -0
- exonware/xwsystem/patterns/registry.py +4 -43
- exonware/xwsystem/plugins/__init__.py +2 -1
- exonware/xwsystem/plugins/base.py +6 -5
- exonware/xwsystem/plugins/contracts.py +94 -158
- exonware/xwsystem/plugins/defs.py +2 -1
- exonware/xwsystem/plugins/errors.py +2 -1
- exonware/xwsystem/py.typed +3 -0
- exonware/xwsystem/query/__init__.py +36 -0
- exonware/xwsystem/query/contracts.py +56 -0
- exonware/xwsystem/query/errors.py +22 -0
- exonware/xwsystem/query/registry.py +128 -0
- exonware/xwsystem/runtime/__init__.py +2 -1
- exonware/xwsystem/runtime/base.py +4 -3
- exonware/xwsystem/runtime/contracts.py +39 -60
- exonware/xwsystem/runtime/defs.py +2 -1
- exonware/xwsystem/runtime/env.py +11 -9
- exonware/xwsystem/runtime/errors.py +2 -1
- exonware/xwsystem/runtime/reflection.py +3 -2
- exonware/xwsystem/security/__init__.py +68 -11
- exonware/xwsystem/security/audit.py +167 -0
- exonware/xwsystem/security/base.py +121 -24
- exonware/xwsystem/security/contracts.py +91 -146
- exonware/xwsystem/security/crypto.py +17 -16
- exonware/xwsystem/security/defs.py +2 -1
- exonware/xwsystem/security/errors.py +2 -1
- exonware/xwsystem/security/facade.py +321 -0
- exonware/xwsystem/security/file_security.py +330 -0
- exonware/xwsystem/security/hazmat.py +11 -8
- exonware/xwsystem/security/monitor.py +372 -0
- exonware/xwsystem/security/path_validator.py +140 -18
- exonware/xwsystem/security/policy.py +357 -0
- exonware/xwsystem/security/resource_limits.py +1 -0
- exonware/xwsystem/security/validator.py +455 -0
- exonware/xwsystem/shared/__init__.py +14 -1
- exonware/xwsystem/shared/base.py +285 -2
- exonware/xwsystem/shared/contracts.py +415 -126
- exonware/xwsystem/shared/defs.py +2 -1
- exonware/xwsystem/shared/errors.py +2 -2
- exonware/xwsystem/shared/xwobject.py +316 -0
- exonware/xwsystem/structures/__init__.py +1 -0
- exonware/xwsystem/structures/base.py +3 -2
- exonware/xwsystem/structures/circular_detector.py +15 -14
- exonware/xwsystem/structures/contracts.py +53 -76
- exonware/xwsystem/structures/defs.py +2 -1
- exonware/xwsystem/structures/errors.py +2 -1
- exonware/xwsystem/structures/tree_walker.py +2 -1
- exonware/xwsystem/threading/__init__.py +21 -4
- exonware/xwsystem/threading/async_primitives.py +6 -5
- exonware/xwsystem/threading/base.py +3 -2
- exonware/xwsystem/threading/contracts.py +87 -143
- exonware/xwsystem/threading/defs.py +2 -1
- exonware/xwsystem/threading/errors.py +2 -1
- exonware/xwsystem/threading/facade.py +175 -0
- exonware/xwsystem/threading/locks.py +1 -0
- exonware/xwsystem/threading/safe_factory.py +1 -0
- exonware/xwsystem/utils/__init__.py +40 -0
- exonware/xwsystem/utils/base.py +22 -21
- exonware/xwsystem/utils/contracts.py +50 -73
- exonware/xwsystem/utils/dt/__init__.py +19 -3
- exonware/xwsystem/utils/dt/base.py +5 -4
- exonware/xwsystem/utils/dt/contracts.py +22 -29
- exonware/xwsystem/utils/dt/defs.py +2 -1
- exonware/xwsystem/utils/dt/errors.py +2 -5
- exonware/xwsystem/utils/dt/formatting.py +88 -2
- exonware/xwsystem/utils/dt/humanize.py +10 -9
- exonware/xwsystem/utils/dt/parsing.py +56 -5
- exonware/xwsystem/utils/dt/timezone_utils.py +2 -24
- exonware/xwsystem/utils/errors.py +2 -4
- exonware/xwsystem/utils/paths.py +1 -0
- exonware/xwsystem/utils/string.py +49 -0
- exonware/xwsystem/utils/test_runner.py +185 -0
- exonware/xwsystem/utils/utils_contracts.py +2 -1
- exonware/xwsystem/utils/web.py +110 -0
- exonware/xwsystem/validation/__init__.py +25 -1
- exonware/xwsystem/validation/base.py +6 -5
- exonware/xwsystem/validation/contracts.py +29 -41
- exonware/xwsystem/validation/data_validator.py +1 -0
- exonware/xwsystem/validation/declarative.py +11 -8
- exonware/xwsystem/validation/defs.py +2 -1
- exonware/xwsystem/validation/errors.py +2 -1
- exonware/xwsystem/validation/facade.py +198 -0
- exonware/xwsystem/validation/fluent_validator.py +22 -19
- exonware/xwsystem/validation/schema_discovery.py +210 -0
- exonware/xwsystem/validation/type_safety.py +2 -1
- exonware/xwsystem/version.py +2 -2
- {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.4.dist-info}/METADATA +71 -4
- exonware_xwsystem-0.1.0.4.dist-info/RECORD +337 -0
- exonware/xwsystem/cli/__init__.py +0 -43
- exonware/xwsystem/cli/console.py +0 -113
- exonware/xwsystem/cli/defs.py +0 -134
- exonware/xwsystem/conf.py +0 -44
- exonware/xwsystem/security/auth.py +0 -484
- exonware_xwsystem-0.1.0.1.dist-info/RECORD +0 -284
- {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.4.dist-info}/WHEEL +0 -0
- {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
#exonware/xwsystem/src/exonware/xwsystem/threading/contracts.py
|
|
2
3
|
"""
|
|
3
4
|
Company: eXonware.com
|
|
4
5
|
Author: Eng. Muhammad AlShehri
|
|
5
6
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.1.0.
|
|
7
|
+
Version: 0.1.0.4
|
|
7
8
|
Generation Date: September 04, 2025
|
|
8
9
|
|
|
9
10
|
Threading protocol interfaces for XWSystem.
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
|
-
from
|
|
13
|
-
from typing import Any, Optional, Union, Iterator, Callable, Coroutine, Awaitable
|
|
13
|
+
from typing import Any, Optional, Iterator, Callable, Coroutine, Awaitable, Protocol, runtime_checkable
|
|
14
14
|
import threading
|
|
15
15
|
import asyncio
|
|
16
16
|
|
|
@@ -28,14 +28,14 @@ from .defs import (
|
|
|
28
28
|
# LOCK INTERFACES
|
|
29
29
|
# ============================================================================
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
@runtime_checkable
|
|
32
|
+
class ILockable(Protocol):
|
|
32
33
|
"""
|
|
33
34
|
Interface for lockable objects.
|
|
34
35
|
|
|
35
36
|
Enforces consistent locking behavior across XWSystem.
|
|
36
37
|
"""
|
|
37
38
|
|
|
38
|
-
@abstractmethod
|
|
39
39
|
def acquire_lock(self, blocking: bool = True, timeout: Optional[float] = None) -> bool:
|
|
40
40
|
"""
|
|
41
41
|
Acquire lock.
|
|
@@ -47,16 +47,14 @@ class ILockable(ABC):
|
|
|
47
47
|
Returns:
|
|
48
48
|
True if lock acquired
|
|
49
49
|
"""
|
|
50
|
-
|
|
50
|
+
...
|
|
51
51
|
|
|
52
|
-
@abstractmethod
|
|
53
52
|
def release_lock(self) -> None:
|
|
54
53
|
"""
|
|
55
54
|
Release lock.
|
|
56
55
|
"""
|
|
57
|
-
|
|
56
|
+
...
|
|
58
57
|
|
|
59
|
-
@abstractmethod
|
|
60
58
|
def is_locked(self) -> bool:
|
|
61
59
|
"""
|
|
62
60
|
Check if object is locked.
|
|
@@ -64,9 +62,8 @@ class ILockable(ABC):
|
|
|
64
62
|
Returns:
|
|
65
63
|
True if locked
|
|
66
64
|
"""
|
|
67
|
-
|
|
65
|
+
...
|
|
68
66
|
|
|
69
|
-
@abstractmethod
|
|
70
67
|
def try_lock(self, timeout: Optional[float] = None) -> bool:
|
|
71
68
|
"""
|
|
72
69
|
Try to acquire lock without blocking.
|
|
@@ -77,9 +74,8 @@ class ILockable(ABC):
|
|
|
77
74
|
Returns:
|
|
78
75
|
True if lock acquired
|
|
79
76
|
"""
|
|
80
|
-
|
|
77
|
+
...
|
|
81
78
|
|
|
82
|
-
@abstractmethod
|
|
83
79
|
def get_lock_type(self) -> LockType:
|
|
84
80
|
"""
|
|
85
81
|
Get lock type.
|
|
@@ -87,9 +83,8 @@ class ILockable(ABC):
|
|
|
87
83
|
Returns:
|
|
88
84
|
Lock type
|
|
89
85
|
"""
|
|
90
|
-
|
|
86
|
+
...
|
|
91
87
|
|
|
92
|
-
@abstractmethod
|
|
93
88
|
def get_lock_owner(self) -> Optional[str]:
|
|
94
89
|
"""
|
|
95
90
|
Get lock owner thread ID.
|
|
@@ -97,9 +92,8 @@ class ILockable(ABC):
|
|
|
97
92
|
Returns:
|
|
98
93
|
Thread ID of lock owner or None
|
|
99
94
|
"""
|
|
100
|
-
|
|
95
|
+
...
|
|
101
96
|
|
|
102
|
-
@abstractmethod
|
|
103
97
|
def get_lock_count(self) -> int:
|
|
104
98
|
"""
|
|
105
99
|
Get lock acquisition count.
|
|
@@ -107,21 +101,21 @@ class ILockable(ABC):
|
|
|
107
101
|
Returns:
|
|
108
102
|
Number of times lock has been acquired
|
|
109
103
|
"""
|
|
110
|
-
|
|
104
|
+
...
|
|
111
105
|
|
|
112
106
|
|
|
113
107
|
# ============================================================================
|
|
114
108
|
# ASYNC INTERFACES
|
|
115
109
|
# ============================================================================
|
|
116
110
|
|
|
117
|
-
|
|
111
|
+
@runtime_checkable
|
|
112
|
+
class IAsync(Protocol):
|
|
118
113
|
"""
|
|
119
114
|
Interface for async operations.
|
|
120
115
|
|
|
121
116
|
Enforces consistent async behavior across XWSystem.
|
|
122
117
|
"""
|
|
123
118
|
|
|
124
|
-
@abstractmethod
|
|
125
119
|
async def async_method(self, *args, **kwargs) -> Any:
|
|
126
120
|
"""
|
|
127
121
|
Execute method asynchronously.
|
|
@@ -133,9 +127,8 @@ class IAsync(ABC):
|
|
|
133
127
|
Returns:
|
|
134
128
|
Method result
|
|
135
129
|
"""
|
|
136
|
-
|
|
130
|
+
...
|
|
137
131
|
|
|
138
|
-
@abstractmethod
|
|
139
132
|
def await_result(self, coroutine: Coroutine) -> Any:
|
|
140
133
|
"""
|
|
141
134
|
Await coroutine result.
|
|
@@ -146,9 +139,8 @@ class IAsync(ABC):
|
|
|
146
139
|
Returns:
|
|
147
140
|
Coroutine result
|
|
148
141
|
"""
|
|
149
|
-
|
|
142
|
+
...
|
|
150
143
|
|
|
151
|
-
@abstractmethod
|
|
152
144
|
def is_async(self) -> bool:
|
|
153
145
|
"""
|
|
154
146
|
Check if object supports async operations.
|
|
@@ -156,9 +148,8 @@ class IAsync(ABC):
|
|
|
156
148
|
Returns:
|
|
157
149
|
True if async supported
|
|
158
150
|
"""
|
|
159
|
-
|
|
151
|
+
...
|
|
160
152
|
|
|
161
|
-
@abstractmethod
|
|
162
153
|
def get_future(self) -> asyncio.Future:
|
|
163
154
|
"""
|
|
164
155
|
Get future for async operation.
|
|
@@ -166,9 +157,8 @@ class IAsync(ABC):
|
|
|
166
157
|
Returns:
|
|
167
158
|
Future object
|
|
168
159
|
"""
|
|
169
|
-
|
|
160
|
+
...
|
|
170
161
|
|
|
171
|
-
@abstractmethod
|
|
172
162
|
def get_async_state(self) -> AsyncState:
|
|
173
163
|
"""
|
|
174
164
|
Get async operation state.
|
|
@@ -176,9 +166,8 @@ class IAsync(ABC):
|
|
|
176
166
|
Returns:
|
|
177
167
|
Current async state
|
|
178
168
|
"""
|
|
179
|
-
|
|
169
|
+
...
|
|
180
170
|
|
|
181
|
-
@abstractmethod
|
|
182
171
|
def cancel_async(self) -> bool:
|
|
183
172
|
"""
|
|
184
173
|
Cancel async operation.
|
|
@@ -186,9 +175,8 @@ class IAsync(ABC):
|
|
|
186
175
|
Returns:
|
|
187
176
|
True if cancelled
|
|
188
177
|
"""
|
|
189
|
-
|
|
178
|
+
...
|
|
190
179
|
|
|
191
|
-
@abstractmethod
|
|
192
180
|
def is_async_completed(self) -> bool:
|
|
193
181
|
"""
|
|
194
182
|
Check if async operation is completed.
|
|
@@ -196,9 +184,8 @@ class IAsync(ABC):
|
|
|
196
184
|
Returns:
|
|
197
185
|
True if completed
|
|
198
186
|
"""
|
|
199
|
-
|
|
187
|
+
...
|
|
200
188
|
|
|
201
|
-
@abstractmethod
|
|
202
189
|
def get_async_result(self) -> Any:
|
|
203
190
|
"""
|
|
204
191
|
Get async operation result.
|
|
@@ -206,21 +193,21 @@ class IAsync(ABC):
|
|
|
206
193
|
Returns:
|
|
207
194
|
Async operation result
|
|
208
195
|
"""
|
|
209
|
-
|
|
196
|
+
...
|
|
210
197
|
|
|
211
198
|
|
|
212
199
|
# ============================================================================
|
|
213
200
|
# THREAD SAFETY INTERFACES
|
|
214
201
|
# ============================================================================
|
|
215
202
|
|
|
216
|
-
|
|
203
|
+
@runtime_checkable
|
|
204
|
+
class IThreadSafe(Protocol):
|
|
217
205
|
"""
|
|
218
206
|
Interface for thread-safe objects.
|
|
219
207
|
|
|
220
208
|
Enforces consistent thread safety across XWSystem.
|
|
221
209
|
"""
|
|
222
210
|
|
|
223
|
-
@abstractmethod
|
|
224
211
|
def thread_safe_method(self, *args, **kwargs) -> Any:
|
|
225
212
|
"""
|
|
226
213
|
Execute method in thread-safe manner.
|
|
@@ -232,9 +219,8 @@ class IThreadSafe(ABC):
|
|
|
232
219
|
Returns:
|
|
233
220
|
Method result
|
|
234
221
|
"""
|
|
235
|
-
|
|
222
|
+
...
|
|
236
223
|
|
|
237
|
-
@abstractmethod
|
|
238
224
|
def get_thread_id(self) -> int:
|
|
239
225
|
"""
|
|
240
226
|
Get current thread ID.
|
|
@@ -242,9 +228,8 @@ class IThreadSafe(ABC):
|
|
|
242
228
|
Returns:
|
|
243
229
|
Thread ID
|
|
244
230
|
"""
|
|
245
|
-
|
|
231
|
+
...
|
|
246
232
|
|
|
247
|
-
@abstractmethod
|
|
248
233
|
def is_thread_safe(self) -> bool:
|
|
249
234
|
"""
|
|
250
235
|
Check if object is thread-safe.
|
|
@@ -252,9 +237,8 @@ class IThreadSafe(ABC):
|
|
|
252
237
|
Returns:
|
|
253
238
|
True if thread-safe
|
|
254
239
|
"""
|
|
255
|
-
|
|
240
|
+
...
|
|
256
241
|
|
|
257
|
-
@abstractmethod
|
|
258
242
|
def get_thread_count(self) -> int:
|
|
259
243
|
"""
|
|
260
244
|
Get number of active threads.
|
|
@@ -262,9 +246,8 @@ class IThreadSafe(ABC):
|
|
|
262
246
|
Returns:
|
|
263
247
|
Number of active threads
|
|
264
248
|
"""
|
|
265
|
-
|
|
249
|
+
...
|
|
266
250
|
|
|
267
|
-
@abstractmethod
|
|
268
251
|
def get_thread_info(self) -> dict[str, Any]:
|
|
269
252
|
"""
|
|
270
253
|
Get thread information.
|
|
@@ -272,9 +255,8 @@ class IThreadSafe(ABC):
|
|
|
272
255
|
Returns:
|
|
273
256
|
Thread information dictionary
|
|
274
257
|
"""
|
|
275
|
-
|
|
258
|
+
...
|
|
276
259
|
|
|
277
|
-
@abstractmethod
|
|
278
260
|
def wait_for_threads(self, timeout: Optional[float] = None) -> bool:
|
|
279
261
|
"""
|
|
280
262
|
Wait for all threads to complete.
|
|
@@ -285,35 +267,33 @@ class IThreadSafe(ABC):
|
|
|
285
267
|
Returns:
|
|
286
268
|
True if all threads completed
|
|
287
269
|
"""
|
|
288
|
-
|
|
270
|
+
...
|
|
289
271
|
|
|
290
|
-
@abstractmethod
|
|
291
272
|
def interrupt_threads(self) -> None:
|
|
292
273
|
"""
|
|
293
274
|
Interrupt all threads.
|
|
294
275
|
"""
|
|
295
|
-
|
|
276
|
+
...
|
|
296
277
|
|
|
297
|
-
@abstractmethod
|
|
298
278
|
def join_threads(self) -> None:
|
|
299
279
|
"""
|
|
300
280
|
Join all threads.
|
|
301
281
|
"""
|
|
302
|
-
|
|
282
|
+
...
|
|
303
283
|
|
|
304
284
|
|
|
305
285
|
# ============================================================================
|
|
306
286
|
# THREAD POOL INTERFACES
|
|
307
287
|
# ============================================================================
|
|
308
288
|
|
|
309
|
-
|
|
289
|
+
@runtime_checkable
|
|
290
|
+
class IThreadPool(Protocol):
|
|
310
291
|
"""
|
|
311
292
|
Interface for thread pool management.
|
|
312
293
|
|
|
313
294
|
Enforces consistent thread pool behavior across XWSystem.
|
|
314
295
|
"""
|
|
315
296
|
|
|
316
|
-
@abstractmethod
|
|
317
297
|
def submit_task(self, func: Callable, *args, **kwargs) -> Any:
|
|
318
298
|
"""
|
|
319
299
|
Submit task to thread pool.
|
|
@@ -326,9 +306,8 @@ class IThreadPool(ABC):
|
|
|
326
306
|
Returns:
|
|
327
307
|
Task result or future
|
|
328
308
|
"""
|
|
329
|
-
|
|
309
|
+
...
|
|
330
310
|
|
|
331
|
-
@abstractmethod
|
|
332
311
|
def submit_async_task(self, func: Callable, *args, **kwargs) -> asyncio.Future:
|
|
333
312
|
"""
|
|
334
313
|
Submit async task to thread pool.
|
|
@@ -341,9 +320,8 @@ class IThreadPool(ABC):
|
|
|
341
320
|
Returns:
|
|
342
321
|
Future object
|
|
343
322
|
"""
|
|
344
|
-
|
|
323
|
+
...
|
|
345
324
|
|
|
346
|
-
@abstractmethod
|
|
347
325
|
def get_pool_size(self) -> int:
|
|
348
326
|
"""
|
|
349
327
|
Get thread pool size.
|
|
@@ -351,9 +329,8 @@ class IThreadPool(ABC):
|
|
|
351
329
|
Returns:
|
|
352
330
|
Number of threads in pool
|
|
353
331
|
"""
|
|
354
|
-
|
|
332
|
+
...
|
|
355
333
|
|
|
356
|
-
@abstractmethod
|
|
357
334
|
def set_pool_size(self, size: int) -> None:
|
|
358
335
|
"""
|
|
359
336
|
Set thread pool size.
|
|
@@ -361,9 +338,8 @@ class IThreadPool(ABC):
|
|
|
361
338
|
Args:
|
|
362
339
|
size: New pool size
|
|
363
340
|
"""
|
|
364
|
-
|
|
341
|
+
...
|
|
365
342
|
|
|
366
|
-
@abstractmethod
|
|
367
343
|
def get_active_count(self) -> int:
|
|
368
344
|
"""
|
|
369
345
|
Get number of active threads.
|
|
@@ -371,9 +347,8 @@ class IThreadPool(ABC):
|
|
|
371
347
|
Returns:
|
|
372
348
|
Number of active threads
|
|
373
349
|
"""
|
|
374
|
-
|
|
350
|
+
...
|
|
375
351
|
|
|
376
|
-
@abstractmethod
|
|
377
352
|
def get_queue_size(self) -> int:
|
|
378
353
|
"""
|
|
379
354
|
Get task queue size.
|
|
@@ -381,9 +356,8 @@ class IThreadPool(ABC):
|
|
|
381
356
|
Returns:
|
|
382
357
|
Number of queued tasks
|
|
383
358
|
"""
|
|
384
|
-
|
|
359
|
+
...
|
|
385
360
|
|
|
386
|
-
@abstractmethod
|
|
387
361
|
def shutdown(self, wait: bool = True) -> None:
|
|
388
362
|
"""
|
|
389
363
|
Shutdown thread pool.
|
|
@@ -391,9 +365,8 @@ class IThreadPool(ABC):
|
|
|
391
365
|
Args:
|
|
392
366
|
wait: Whether to wait for tasks to complete
|
|
393
367
|
"""
|
|
394
|
-
|
|
368
|
+
...
|
|
395
369
|
|
|
396
|
-
@abstractmethod
|
|
397
370
|
def is_shutdown(self) -> bool:
|
|
398
371
|
"""
|
|
399
372
|
Check if thread pool is shutdown.
|
|
@@ -401,21 +374,21 @@ class IThreadPool(ABC):
|
|
|
401
374
|
Returns:
|
|
402
375
|
True if shutdown
|
|
403
376
|
"""
|
|
404
|
-
|
|
377
|
+
...
|
|
405
378
|
|
|
406
379
|
|
|
407
380
|
# ============================================================================
|
|
408
381
|
# CONCURRENCY CONTROL INTERFACES
|
|
409
382
|
# ============================================================================
|
|
410
383
|
|
|
411
|
-
|
|
384
|
+
@runtime_checkable
|
|
385
|
+
class IConcurrencyControl(Protocol):
|
|
412
386
|
"""
|
|
413
387
|
Interface for concurrency control.
|
|
414
388
|
|
|
415
389
|
Enforces consistent concurrency control across XWSystem.
|
|
416
390
|
"""
|
|
417
391
|
|
|
418
|
-
@abstractmethod
|
|
419
392
|
def acquire_resource(self, resource_id: str, timeout: Optional[float] = None) -> bool:
|
|
420
393
|
"""
|
|
421
394
|
Acquire resource for exclusive access.
|
|
@@ -427,9 +400,8 @@ class IConcurrencyControl(ABC):
|
|
|
427
400
|
Returns:
|
|
428
401
|
True if resource acquired
|
|
429
402
|
"""
|
|
430
|
-
|
|
403
|
+
...
|
|
431
404
|
|
|
432
|
-
@abstractmethod
|
|
433
405
|
def release_resource(self, resource_id: str) -> None:
|
|
434
406
|
"""
|
|
435
407
|
Release resource.
|
|
@@ -437,9 +409,8 @@ class IConcurrencyControl(ABC):
|
|
|
437
409
|
Args:
|
|
438
410
|
resource_id: Resource identifier
|
|
439
411
|
"""
|
|
440
|
-
|
|
412
|
+
...
|
|
441
413
|
|
|
442
|
-
@abstractmethod
|
|
443
414
|
def is_resource_available(self, resource_id: str) -> bool:
|
|
444
415
|
"""
|
|
445
416
|
Check if resource is available.
|
|
@@ -450,9 +421,8 @@ class IConcurrencyControl(ABC):
|
|
|
450
421
|
Returns:
|
|
451
422
|
True if available
|
|
452
423
|
"""
|
|
453
|
-
|
|
424
|
+
...
|
|
454
425
|
|
|
455
|
-
@abstractmethod
|
|
456
426
|
def get_resource_owner(self, resource_id: str) -> Optional[str]:
|
|
457
427
|
"""
|
|
458
428
|
Get resource owner.
|
|
@@ -463,9 +433,8 @@ class IConcurrencyControl(ABC):
|
|
|
463
433
|
Returns:
|
|
464
434
|
Owner thread ID or None
|
|
465
435
|
"""
|
|
466
|
-
|
|
436
|
+
...
|
|
467
437
|
|
|
468
|
-
@abstractmethod
|
|
469
438
|
def wait_for_resource(self, resource_id: str, timeout: Optional[float] = None) -> bool:
|
|
470
439
|
"""
|
|
471
440
|
Wait for resource to become available.
|
|
@@ -477,9 +446,8 @@ class IConcurrencyControl(ABC):
|
|
|
477
446
|
Returns:
|
|
478
447
|
True if resource became available
|
|
479
448
|
"""
|
|
480
|
-
|
|
449
|
+
...
|
|
481
450
|
|
|
482
|
-
@abstractmethod
|
|
483
451
|
def get_concurrency_mode(self) -> ConcurrencyMode:
|
|
484
452
|
"""
|
|
485
453
|
Get concurrency mode.
|
|
@@ -487,9 +455,8 @@ class IConcurrencyControl(ABC):
|
|
|
487
455
|
Returns:
|
|
488
456
|
Current concurrency mode
|
|
489
457
|
"""
|
|
490
|
-
|
|
458
|
+
...
|
|
491
459
|
|
|
492
|
-
@abstractmethod
|
|
493
460
|
def set_concurrency_mode(self, mode: ConcurrencyMode) -> None:
|
|
494
461
|
"""
|
|
495
462
|
Set concurrency mode.
|
|
@@ -497,21 +464,21 @@ class IConcurrencyControl(ABC):
|
|
|
497
464
|
Args:
|
|
498
465
|
mode: Concurrency mode to set
|
|
499
466
|
"""
|
|
500
|
-
|
|
467
|
+
...
|
|
501
468
|
|
|
502
469
|
|
|
503
470
|
# ============================================================================
|
|
504
471
|
# SYNCHRONIZATION INTERFACES
|
|
505
472
|
# ============================================================================
|
|
506
473
|
|
|
507
|
-
|
|
474
|
+
@runtime_checkable
|
|
475
|
+
class ISynchronization(Protocol):
|
|
508
476
|
"""
|
|
509
477
|
Interface for synchronization primitives.
|
|
510
478
|
|
|
511
479
|
Enforces consistent synchronization across XWSystem.
|
|
512
480
|
"""
|
|
513
481
|
|
|
514
|
-
@abstractmethod
|
|
515
482
|
def wait(self, timeout: Optional[float] = None) -> bool:
|
|
516
483
|
"""
|
|
517
484
|
Wait for condition.
|
|
@@ -522,37 +489,32 @@ class ISynchronization(ABC):
|
|
|
522
489
|
Returns:
|
|
523
490
|
True if condition met
|
|
524
491
|
"""
|
|
525
|
-
|
|
492
|
+
...
|
|
526
493
|
|
|
527
|
-
@abstractmethod
|
|
528
494
|
def notify(self) -> None:
|
|
529
495
|
"""
|
|
530
496
|
Notify waiting threads.
|
|
531
497
|
"""
|
|
532
|
-
|
|
498
|
+
...
|
|
533
499
|
|
|
534
|
-
@abstractmethod
|
|
535
500
|
def notify_all(self) -> None:
|
|
536
501
|
"""
|
|
537
502
|
Notify all waiting threads.
|
|
538
503
|
"""
|
|
539
|
-
|
|
504
|
+
...
|
|
540
505
|
|
|
541
|
-
@abstractmethod
|
|
542
506
|
def signal(self) -> None:
|
|
543
507
|
"""
|
|
544
508
|
Signal condition.
|
|
545
509
|
"""
|
|
546
|
-
|
|
510
|
+
...
|
|
547
511
|
|
|
548
|
-
@abstractmethod
|
|
549
512
|
def reset(self) -> None:
|
|
550
513
|
"""
|
|
551
514
|
Reset synchronization primitive.
|
|
552
515
|
"""
|
|
553
|
-
|
|
516
|
+
...
|
|
554
517
|
|
|
555
|
-
@abstractmethod
|
|
556
518
|
def is_set(self) -> bool:
|
|
557
519
|
"""
|
|
558
520
|
Check if condition is set.
|
|
@@ -560,9 +522,8 @@ class ISynchronization(ABC):
|
|
|
560
522
|
Returns:
|
|
561
523
|
True if set
|
|
562
524
|
"""
|
|
563
|
-
|
|
525
|
+
...
|
|
564
526
|
|
|
565
|
-
@abstractmethod
|
|
566
527
|
def get_waiting_count(self) -> int:
|
|
567
528
|
"""
|
|
568
529
|
Get number of waiting threads.
|
|
@@ -570,21 +531,21 @@ class ISynchronization(ABC):
|
|
|
570
531
|
Returns:
|
|
571
532
|
Number of waiting threads
|
|
572
533
|
"""
|
|
573
|
-
|
|
534
|
+
...
|
|
574
535
|
|
|
575
536
|
|
|
576
537
|
# ============================================================================
|
|
577
538
|
# DEADLOCK DETECTION INTERFACES
|
|
578
539
|
# ============================================================================
|
|
579
540
|
|
|
580
|
-
|
|
541
|
+
@runtime_checkable
|
|
542
|
+
class IDeadlockDetection(Protocol):
|
|
581
543
|
"""
|
|
582
544
|
Interface for deadlock detection.
|
|
583
545
|
|
|
584
546
|
Enforces consistent deadlock detection across XWSystem.
|
|
585
547
|
"""
|
|
586
548
|
|
|
587
|
-
@abstractmethod
|
|
588
549
|
def detect_deadlock(self) -> list[dict[str, Any]]:
|
|
589
550
|
"""
|
|
590
551
|
Detect deadlocks.
|
|
@@ -592,9 +553,8 @@ class IDeadlockDetection(ABC):
|
|
|
592
553
|
Returns:
|
|
593
554
|
List of deadlock information
|
|
594
555
|
"""
|
|
595
|
-
|
|
556
|
+
...
|
|
596
557
|
|
|
597
|
-
@abstractmethod
|
|
598
558
|
def is_deadlocked(self) -> bool:
|
|
599
559
|
"""
|
|
600
560
|
Check if system is deadlocked.
|
|
@@ -602,9 +562,8 @@ class IDeadlockDetection(ABC):
|
|
|
602
562
|
Returns:
|
|
603
563
|
True if deadlocked
|
|
604
564
|
"""
|
|
605
|
-
|
|
565
|
+
...
|
|
606
566
|
|
|
607
|
-
@abstractmethod
|
|
608
567
|
def resolve_deadlock(self, deadlock_info: dict[str, Any]) -> bool:
|
|
609
568
|
"""
|
|
610
569
|
Resolve deadlock.
|
|
@@ -615,9 +574,8 @@ class IDeadlockDetection(ABC):
|
|
|
615
574
|
Returns:
|
|
616
575
|
True if resolved
|
|
617
576
|
"""
|
|
618
|
-
|
|
577
|
+
...
|
|
619
578
|
|
|
620
|
-
@abstractmethod
|
|
621
579
|
def get_lock_graph(self) -> dict[str, list[str]]:
|
|
622
580
|
"""
|
|
623
581
|
Get lock dependency graph.
|
|
@@ -625,9 +583,8 @@ class IDeadlockDetection(ABC):
|
|
|
625
583
|
Returns:
|
|
626
584
|
Lock dependency graph
|
|
627
585
|
"""
|
|
628
|
-
|
|
586
|
+
...
|
|
629
587
|
|
|
630
|
-
@abstractmethod
|
|
631
588
|
def add_lock_dependency(self, resource1: str, resource2: str) -> None:
|
|
632
589
|
"""
|
|
633
590
|
Add lock dependency.
|
|
@@ -636,9 +593,8 @@ class IDeadlockDetection(ABC):
|
|
|
636
593
|
resource1: First resource
|
|
637
594
|
resource2: Second resource
|
|
638
595
|
"""
|
|
639
|
-
|
|
596
|
+
...
|
|
640
597
|
|
|
641
|
-
@abstractmethod
|
|
642
598
|
def remove_lock_dependency(self, resource1: str, resource2: str) -> None:
|
|
643
599
|
"""
|
|
644
600
|
Remove lock dependency.
|
|
@@ -647,9 +603,8 @@ class IDeadlockDetection(ABC):
|
|
|
647
603
|
resource1: First resource
|
|
648
604
|
resource2: Second resource
|
|
649
605
|
"""
|
|
650
|
-
|
|
606
|
+
...
|
|
651
607
|
|
|
652
|
-
@abstractmethod
|
|
653
608
|
def get_deadlock_prevention_mode(self) -> bool:
|
|
654
609
|
"""
|
|
655
610
|
Get deadlock prevention mode.
|
|
@@ -657,9 +612,8 @@ class IDeadlockDetection(ABC):
|
|
|
657
612
|
Returns:
|
|
658
613
|
True if prevention enabled
|
|
659
614
|
"""
|
|
660
|
-
|
|
615
|
+
...
|
|
661
616
|
|
|
662
|
-
@abstractmethod
|
|
663
617
|
def set_deadlock_prevention_mode(self, enabled: bool) -> None:
|
|
664
618
|
"""
|
|
665
619
|
Set deadlock prevention mode.
|
|
@@ -667,21 +621,21 @@ class IDeadlockDetection(ABC):
|
|
|
667
621
|
Args:
|
|
668
622
|
enabled: Whether to enable prevention
|
|
669
623
|
"""
|
|
670
|
-
|
|
624
|
+
...
|
|
671
625
|
|
|
672
626
|
|
|
673
627
|
# ============================================================================
|
|
674
628
|
# THREAD MONITORING INTERFACES
|
|
675
629
|
# ============================================================================
|
|
676
630
|
|
|
677
|
-
|
|
631
|
+
@runtime_checkable
|
|
632
|
+
class IThreadMonitor(Protocol):
|
|
678
633
|
"""
|
|
679
634
|
Interface for thread monitoring.
|
|
680
635
|
|
|
681
636
|
Enforces consistent thread monitoring across XWSystem.
|
|
682
637
|
"""
|
|
683
638
|
|
|
684
|
-
@abstractmethod
|
|
685
639
|
def get_thread_stats(self) -> dict[str, Any]:
|
|
686
640
|
"""
|
|
687
641
|
Get thread statistics.
|
|
@@ -689,9 +643,8 @@ class IThreadMonitor(ABC):
|
|
|
689
643
|
Returns:
|
|
690
644
|
Thread statistics dictionary
|
|
691
645
|
"""
|
|
692
|
-
|
|
646
|
+
...
|
|
693
647
|
|
|
694
|
-
@abstractmethod
|
|
695
648
|
def get_thread_list(self) -> list[dict[str, Any]]:
|
|
696
649
|
"""
|
|
697
650
|
Get list of all threads.
|
|
@@ -699,9 +652,8 @@ class IThreadMonitor(ABC):
|
|
|
699
652
|
Returns:
|
|
700
653
|
List of thread information
|
|
701
654
|
"""
|
|
702
|
-
|
|
655
|
+
...
|
|
703
656
|
|
|
704
|
-
@abstractmethod
|
|
705
657
|
def get_thread_by_id(self, thread_id: int) -> Optional[dict[str, Any]]:
|
|
706
658
|
"""
|
|
707
659
|
Get thread by ID.
|
|
@@ -712,9 +664,8 @@ class IThreadMonitor(ABC):
|
|
|
712
664
|
Returns:
|
|
713
665
|
Thread information or None
|
|
714
666
|
"""
|
|
715
|
-
|
|
667
|
+
...
|
|
716
668
|
|
|
717
|
-
@abstractmethod
|
|
718
669
|
def monitor_thread_performance(self, thread_id: int) -> dict[str, Any]:
|
|
719
670
|
"""
|
|
720
671
|
Monitor thread performance.
|
|
@@ -725,9 +676,8 @@ class IThreadMonitor(ABC):
|
|
|
725
676
|
Returns:
|
|
726
677
|
Performance metrics
|
|
727
678
|
"""
|
|
728
|
-
|
|
679
|
+
...
|
|
729
680
|
|
|
730
|
-
@abstractmethod
|
|
731
681
|
def detect_thread_leaks(self) -> list[int]:
|
|
732
682
|
"""
|
|
733
683
|
Detect thread leaks.
|
|
@@ -735,9 +685,8 @@ class IThreadMonitor(ABC):
|
|
|
735
685
|
Returns:
|
|
736
686
|
List of leaked thread IDs
|
|
737
687
|
"""
|
|
738
|
-
|
|
688
|
+
...
|
|
739
689
|
|
|
740
|
-
@abstractmethod
|
|
741
690
|
def cleanup_thread_leaks(self, thread_ids: list[int]) -> int:
|
|
742
691
|
"""
|
|
743
692
|
Cleanup thread leaks.
|
|
@@ -748,9 +697,8 @@ class IThreadMonitor(ABC):
|
|
|
748
697
|
Returns:
|
|
749
698
|
Number of threads cleaned up
|
|
750
699
|
"""
|
|
751
|
-
|
|
700
|
+
...
|
|
752
701
|
|
|
753
|
-
@abstractmethod
|
|
754
702
|
def get_thread_priority(self, thread_id: int) -> ThreadPriority:
|
|
755
703
|
"""
|
|
756
704
|
Get thread priority.
|
|
@@ -761,9 +709,8 @@ class IThreadMonitor(ABC):
|
|
|
761
709
|
Returns:
|
|
762
710
|
Thread priority
|
|
763
711
|
"""
|
|
764
|
-
|
|
712
|
+
...
|
|
765
713
|
|
|
766
|
-
@abstractmethod
|
|
767
714
|
def set_thread_priority(self, thread_id: int, priority: ThreadPriority) -> bool:
|
|
768
715
|
"""
|
|
769
716
|
Set thread priority.
|
|
@@ -775,31 +722,30 @@ class IThreadMonitor(ABC):
|
|
|
775
722
|
Returns:
|
|
776
723
|
True if set successfully
|
|
777
724
|
"""
|
|
778
|
-
|
|
725
|
+
...
|
|
779
726
|
|
|
780
727
|
|
|
781
728
|
# ============================================================================
|
|
782
729
|
# ASYNC CONTEXT MANAGER INTERFACES
|
|
783
730
|
# ============================================================================
|
|
784
731
|
|
|
785
|
-
|
|
732
|
+
@runtime_checkable
|
|
733
|
+
class IAsyncContextManager(Protocol):
|
|
786
734
|
"""
|
|
787
735
|
Interface for async context managers.
|
|
788
736
|
|
|
789
737
|
Enforces consistent async context management across XWSystem.
|
|
790
738
|
"""
|
|
791
739
|
|
|
792
|
-
|
|
793
|
-
async def __aenter__(self) -> 'IAsyncContextManager':
|
|
740
|
+
async def __aenter__(self) -> IAsyncContextManager:
|
|
794
741
|
"""
|
|
795
742
|
Async context manager entry.
|
|
796
743
|
|
|
797
744
|
Returns:
|
|
798
745
|
Self
|
|
799
746
|
"""
|
|
800
|
-
|
|
747
|
+
...
|
|
801
748
|
|
|
802
|
-
@abstractmethod
|
|
803
749
|
async def __aexit__(self, exc_type: type, exc_val: Exception, exc_tb: Any) -> bool:
|
|
804
750
|
"""
|
|
805
751
|
Async context manager exit.
|
|
@@ -812,9 +758,8 @@ class IAsyncContextManager(ABC):
|
|
|
812
758
|
Returns:
|
|
813
759
|
True if exception handled
|
|
814
760
|
"""
|
|
815
|
-
|
|
761
|
+
...
|
|
816
762
|
|
|
817
|
-
@abstractmethod
|
|
818
763
|
def is_async_context_active(self) -> bool:
|
|
819
764
|
"""
|
|
820
765
|
Check if async context is active.
|
|
@@ -822,9 +767,8 @@ class IAsyncContextManager(ABC):
|
|
|
822
767
|
Returns:
|
|
823
768
|
True if active
|
|
824
769
|
"""
|
|
825
|
-
|
|
770
|
+
...
|
|
826
771
|
|
|
827
|
-
@abstractmethod
|
|
828
772
|
def get_async_context_info(self) -> dict[str, Any]:
|
|
829
773
|
"""
|
|
830
774
|
Get async context information.
|
|
@@ -832,4 +776,4 @@ class IAsyncContextManager(ABC):
|
|
|
832
776
|
Returns:
|
|
833
777
|
Context information dictionary
|
|
834
778
|
"""
|
|
835
|
-
|
|
779
|
+
...
|