Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ProcessManager to ensure that no more than one Tribler GUI/Core p…
…rocess runs locally at any moment (#7212) * Rename QtSingleApplication attributes from camelCase to snake_case * Rename QtSingleApplication method: close() -> cleanup_crashed_server() * Add ProcessLocker * Fix add ProcessLocker * Renaming: ProcessLocker -> ProcessManager * Renaming: ProcessInfo -> TriblerProcess * Make to_json & from_json static methods; remove to_dict * Rename: active process -> primary process * Split process_manager into tribler_process & tribler_process_manager * Reduce the using of global variables * Move tribler_process and tribler_process_manager into a process_manager subpackage * Remove unnecessary line of code * Formatting * Refactoring: integrate ProcessManager.connect() into ProcessManager.transaction() * Renaming: ProcessManager.transaction() -> ProcessManager._connect() * Renaming: ProcessManager.filename -> ProcessManager.db_filepath * Remove TriblerProcess.other_params * Simplify set_error() signature; remove TriblerProcess.error_info & json-related methods * Remove shutdown_request_pid & shutdown_requested_at * Remove _before_insert_check() * Make the code a bit easier to read * Add a docstring to a `with_retry` decorator * Remove ProcessManager._get_file_name() * Extract ProcessManager._load_primary_process() from ProcessManager.atomic_get_primary_process() * Refactor the process - manager interaction, API and tests * Clean up old exception logic * Auto-delete old records from the database * Add comments to SQL scripts * Add docstrings to ProcessManager methods * Extract `with_retry` decorator to a separate utils module and make it applicable both for ProcessManager and TriblerProcess methods * Specify exact columns in SELECT commands * Rename: TriblerProcess.descrive() -> TriblerProcess.__str__() * Fix TriblerProcess.is_current_process() * TriblerProcess.mark_finished() -> TriblerProcess.finish() * Some docstrings added * Remove ProcessChecker * Extract columns of SELECT queries to a separate constant * Set Core API port in RESTManager * Create current_process outside of ProcessManager * Refactoring: ProcessManager.atomic_get_primary_process() -> TriblerProcess.become_primary() * Use assignment expression * Make ProcessManager.logger an attribute instead of a property * Refactor QtSingleApplication; pass start_local_server argument instead of another_process_is_primary * Satisfy linter * Make primary and canceled true boolean attributes * Fix test_become_primary and add comments to it * Split test_tribler_process_is_running to five tests * Split test_tribler_process_set_error to three tests * Simplify test_tribler_process_save * Simplify TriblerProcess tests * Add an additional safety belt for test_global_process_manager * Rename: set_error -> set_error_for_current_process; add docstring * Remove set_error_for_current_process function * Fix empty info log messages * Fix: test_load_logger should not change log configuration as it can affect the subsequent tests * Non-primary Tribler processes should not write logs into files * Add try/finally block to make test_global_process_manager extra safe * Remove test_global_process_manager according to @drew2a request
- Loading branch information
Showing
29 changed files
with
913 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.