Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple instances of Tribler on Flatpak #7621

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tribler/core/utilities/process_manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def primary_process_rowid(self, kind: ProcessKind) -> Optional[int]:
row = cursor.fetchone()
if row is not None:
process = TriblerProcess.from_row(self, row)
if process.is_running():
if process.is_current_process() or process.is_running():
return process.rowid

# Process is not running anymore; mark it as not primary
Expand Down
2 changes: 1 addition & 1 deletion src/tribler/core/utilities/process_manager/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def current_process(cls, kind: ProcessKind,

def is_current_process(self) -> bool:
"""Returns True if the object represents the current process"""
return self.pid == os.getpid() and self.is_running()
return self.pid == os.getpid()

@with_retry
def become_primary(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# pylint: disable=protected-access


@patch('os.getpid', new=lambda: 1)
def test_become_primary(process_manager: ProcessManager):
# Initially process manager fixture creates a primary current process that is a single process in DB
p1 = process_manager.current_process
Expand Down