Bug 2007664
Summary: | Fedora Python imports lots of additional modules on startup | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Christian Heimes <cheimes> |
Component: | abrt | Assignee: | abrt <abrt-devel-list> |
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 35 | CC: | abrt-devel-list, abrt-sig, awilliam, cstratak, jakub, jmilan, mgrabovs, mhroncok, michal.toman, mmarusak, python-maint, python-sig, thrnciar, torsava, vstinner |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | AcceptedFreezeException | ||
Fixed In Version: | abrt-2.14.6-4.fc34 abrt-2.14.6-9.fc35 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2021-10-07 23:31:47 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1891956 |
Description
Christian Heimes
2021-09-24 14:09:57 UTC
Changing the component to abrt to get feedback from the maintainers. /usr/lib/python3.9/site-packages/abrt3.pth has: import abrt_exception_handler3 /usr/lib/python3.9/site-packages/abrt_exception_handler3.py has: import sys import os from systemd import journal I think ideally, abrt_exception_handler3 could lazy import: Even this helps a lot: def syslog(msg): """Log message to system logger (journal)""" from systemd import journal journal.send(msg) On rawhide: - no python3-abrt-addon installed: 32 modules - python3-abrt-addon installed: 85 modules - python3-abrt-addon with the modification from above: 33 modules The plugin could even do the right thing and module-level importing os, but that currently does not make any difference. My diff: @@ -21,13 +21,11 @@ """ import sys -import os -from systemd import journal def syslog(msg): """Log message to system logger (journal)""" - + from systemd import journal journal.send(msg) @@ -68,6 +66,8 @@ def write_dump(tb_text, tb): + import os + if sys.argv[0][0] == "/": executable = os.path.abspath(sys.argv[0]) else: @@ -117,7 +117,7 @@ # Restore original exception handler sys.excepthook = sys.__excepthook__ # pylint: disable-msg=E1101 - import errno + import errno, os # Ignore Ctrl-C # SystemExit rhbz#636913 -> this exception is not an error Christian, as for the other 14 modules imported on your workstation: 'bkr', 'google', 'importlib', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.abc', 'importlib.machinery', 'importlib.util', 'paste', 'ruamel', 'sphinxcontrib', 'typing', 'typing.io', 'typing.re' I believe those are caused by some old-school namespace packages with files like /usr/lib/python3.9/site-packages/ruamel.yaml-0.16.6-py3.9-nspkg.pth: import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('ruamel',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('ruamel', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('ruamel', [os.path.dirname(p)])));m = m or sys.modules.setdefault('ruamel', types.ModuleType('ruamel'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p) Not much we can do about those except talking to upstream not to do this anymore. > The plugin could even do the right thing and module-level importing os...
Correction: And **stop** module-level importing os...
Upstream PR: https://github.com/abrt/abrt/pull/1580 Pull request merged. The change will appear in the next release of abrt. (In reply to Matej Grabovsky from comment #6) > The change will appear in the next release of abrt. Will that happen in time for Fedora 35 final freeze? If not, I'd rather see that backported. OK, I'll push a backport for active releases. Thanks! FEDORA-2021-db079c289a has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-db079c289a FEDORA-2021-db079c289a has been pushed to the Fedora 34 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-db079c289a` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-db079c289a See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2021-db079c289a has been pushed to the Fedora 34 stable repository. If problem still persists, please make note of it in this bug report. This has still not reached F35. I'd really like to see it on the media. FEDORA-2021-418a00501f has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2021-418a00501f +3 in https://pagure.io/fedora-qa/blocker-review/issue/519 , marking accepted. FEDORA-2021-418a00501f has been pushed to the Fedora 35 stable repository. If problem still persists, please make note of it in this bug report. |