-
Notifications
You must be signed in to change notification settings - Fork 452
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
Fixes 1-Click release for 7.11 #6568
Changes from all commits
8ed9bb3
43f7461
446ef47
7e036c4
f8278c7
eec8c2c
15c4d4f
7e8c1d4
0b00a1b
b4f7891
27efb4e
fe08244
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
# A fix for "LookupError: unknown encoding: idna" error. | ||
# Adding encodings.idna to hiddenimports is not enough. | ||
# https://github.com/pyinstaller/pyinstaller/issues/1113 | ||
import encodings.idna # pylint: disable=unused-import | ||
import logging.config | ||
import os | ||
import sys | ||
|
||
from PyQt5.QtCore import QSettings | ||
|
||
from tribler_common.sentry_reporter.sentry_reporter import SentryReporter, SentryStrategy | ||
from tribler_common.sentry_reporter.sentry_scrubber import SentryScrubber | ||
|
||
logger = logging.getLogger(__name__) | ||
CONFIG_FILE_NAME = 'triblerd.conf' | ||
|
||
# pylint: disable=import-outside-toplevel, ungrouped-imports | ||
|
||
def init_sentry_reporter(): | ||
from tribler_common.sentry_reporter.sentry_reporter import SentryReporter, SentryStrategy | ||
from tribler_common.sentry_reporter.sentry_scrubber import SentryScrubber | ||
|
||
""" Initialise sentry reporter | ||
|
||
We use `sentry_url` as a URL for normal tribler mode and TRIBLER_TEST_SENTRY_URL | ||
|
@@ -135,7 +139,10 @@ def init_boot_logger(): | |
logger.info("Shutting down Tribler") | ||
if trace_logger: | ||
trace_logger.close() | ||
|
||
# Flush all the logs to make sure it is written to file before it exits | ||
for handler in logging.getLogger().handlers: | ||
handler.flush() | ||
|
||
SentryReporter.global_strategy = SentryStrategy.SEND_SUPPRESSED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this Sentry suppression, it sometimes happens that an error takes place during the Tribler shutdown. Then Sentry tries to display the dialog window, but the Qt state is already partially destructed, which leads to mysterious crashes. |
||
raise |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,8 +89,14 @@ def should_kill_other_tribler_instances(root_state_dir): | |
if current_pid != old_pid and old_pid > 0: | ||
# If the old process is a zombie, simply kill it and restart Tribler | ||
old_process = psutil.Process(old_pid) | ||
logger.info(f'Old process status: {old_process.status()}') | ||
if old_process.status() == psutil.STATUS_ZOMBIE: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes Tribler crashes on psutil.NoSuchProcess exception when reading |
||
try: | ||
old_process_status = old_process.status() | ||
except psutil.NoSuchProcess: | ||
logger.info('Old process not found') | ||
return | ||
|
||
logger.info(f'Old process status: {old_process_status}') | ||
if old_process_status == psutil.STATUS_ZOMBIE: | ||
kill_tribler_process(old_process) | ||
restart_tribler_properly() | ||
return | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,12 +174,15 @@ def start_tribler_core(base_path, api_port, api_key, root_state_dir, gui_test_mo | |
loop = asyncio.get_event_loop() | ||
loop.set_exception_handler(CoreExceptionHandler.unhandled_error_observer) | ||
|
||
loop.run_until_complete(core_session(config, components=list(components_gen(config)))) | ||
|
||
if trace_logger: | ||
trace_logger.close() | ||
|
||
process_checker.remove_lock_file() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We must always remove the lock file on Tribler crash to re-run the application tester reliably, so try/finally block is necessary here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our lock file mechanics are broken, as it was built on the assumption that OS does not reuse PIDs before system restart. This is not true, Windows especially reuses process IDs quickly, and that leads to many non-obvious bugs (like, Tribler is trying to kill some innocent unrelated process, assuming this is the previous Tribler core). I will open a separate issue for that. |
||
# Flush the logs to the file before exiting | ||
for handler in logging.getLogger().handlers: | ||
handler.flush() | ||
try: | ||
loop.run_until_complete(core_session(config, components=list(components_gen(config)))) | ||
finally: | ||
if trace_logger: | ||
trace_logger.close() | ||
|
||
logger.info('Remove lock file') | ||
process_checker.remove_lock_file() | ||
|
||
# Flush the logs to the file before exiting | ||
for handler in logging.getLogger().handlers: | ||
handler.flush() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,12 @@ def on_core_read_ready(self): | |
if b'Traceback' in raw_output: | ||
self.core_traceback = decoded_output | ||
self.core_traceback_timestamp = int(round(time.time() * 1000)) | ||
print(decoded_output.strip()) # noqa: T001 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes Tribler crashes when trying to write data to stdout during the shutdown |
||
try: | ||
print(decoded_output.strip()) # noqa: T001 | ||
except OSError: | ||
# Possible reason - cannot write to stdout as it was already closed during the application shutdown | ||
if not self.shutting_down: | ||
raise | ||
|
||
def on_core_finished(self, exit_code, exit_status): | ||
if self.shutting_down and self.should_stop_on_shutdown: | ||
|
@@ -197,7 +202,9 @@ def on_received_state(self, state): | |
raise RuntimeError(state['last_exception']) | ||
|
||
def stop(self, stop_app_on_shutdown=True): | ||
self._logger.info("Stopping Core manager") | ||
if self.core_process or self.is_core_running: | ||
self._logger.info("Sending shutdown request to Tribler Core") | ||
self.events_manager.shutting_down = True | ||
TriblerNetworkRequest("shutdown", lambda _: None, method="PUT", priority=QNetworkRequest.HighPriority) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,18 +93,19 @@ hiddenimports = [ | |
'csv', | ||
'dataclasses', # https://github.com/pyinstaller/pyinstaller/issues/5432 | ||
'ecdsa', | ||
'pyaes', | ||
'PIL', | ||
'scrypt', '_scrypt', | ||
'sqlalchemy', 'sqlalchemy.ext.baked', 'sqlalchemy.ext.declarative', | ||
'pkg_resources', # 'pkg_resources.py2_warn', # Workaround PyInstaller & SetupTools, https://github.com/pypa/setuptools/issues/1963 | ||
'requests', | ||
'pyaes', | ||
'pydantic', | ||
'PyQt5.QtTest', | ||
'pyqtgraph', | ||
'pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5', | ||
'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5', | ||
'pyqtgraph.imageview.ImageViewTemplate_pyqt5', | ||
'PyQt5.QtTest', | ||
'requests', | ||
'scrypt', '_scrypt', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know! I'll remove them in a separate PR after additional testing |
||
'sqlalchemy', 'sqlalchemy.ext.baked', 'sqlalchemy.ext.declarative', | ||
'typing_extensions', | ||
] + widget_files + pony_deps + get_sentry_hooks() | ||
|
||
# https://github.com/pyinstaller/pyinstaller/issues/5359 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without --no-binary PyInstaller does not include this module into the Tribler exe file on Windows
The latest version of typing_extension (4.0.0) is currently not working as well.
After #6534 we can move it into requirements with --no-binary specification