Skip to content

Commit

Permalink
Fix swsscommon import protobuf error
Browse files Browse the repository at this point in the history
```
Current thread 0x00007f4ce5a01740 (most recent call first):
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1108 in create_module
  File "<frozen importlib._bootstrap>", line 565 in module_from_spec
  File "<frozen importlib._bootstrap>", line 666 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1058 in _handle_fromlist
  File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 13 in <module>
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 790 in exec_module
  File "<frozen importlib._bootstrap>", line 680 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1058 in _handle_fromlist
  File "/sonic/src/sonic-platform-daemons/sonic-ycabled/tests/test_y_cable_helper.py", line 3 in <module>
  File "/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py", line 170 in exec_module
  File "<frozen importlib._bootstrap>", line 680 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "<frozen importlib._bootstrap>", line 1030 in _gcd_import
  File "/usr/lib/python3.9/importlib/__init__.py", line 127 in import_module
  File "/usr/lib/python3/dist-packages/_pytest/pathlib.py", line 520 in import_path
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 552 in _importtestmodule
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 484 in _getobj
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 288 in obj
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 500 in _inject_setup_module_fixture
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 487 in collect
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 324 in <lambda>
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 294 in from_call
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 324 in pytest_make_collect_report
  File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 441 in collect_one_node
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 768 in genitems
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 771 in genitems
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 568 in _perform_collect
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 516 in perform_collect
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 306 in pytest_collection
  File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 295 in _main
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 240 in wrap_session
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 289 in pytest_cmdline_main
  File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83 in <lambda>
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 157 in main
  File "/usr/local/lib/python3.9/dist-packages/ptr.py", line 220 in run_tests
  File "/usr/local/lib/python3.9/dist-packages/ptr.py", line 209 in run
  File "/usr/lib/python3.9/distutils/dist.py", line 985 in run_command
  File "/usr/lib/python3.9/distutils/dist.py", line 966 in run_commands
  File "/usr/lib/python3.9/distutils/core.py", line 148 in setup
  File "/usr/local/lib/python3.9/dist-packages/setuptools/__init__.py", line 163 in setup
  File "/sonic/src/sonic-platform-daemons/sonic-ycabled/setup.py", line 30 in <module>
Aborted (core dumped)
```

By GDB and get the error trace of protobuf like :
```
    at assert.c:92
    function=function@entry=0x7ffff7faa1c0 <__PRETTY_FUNCTION__.0> "__pthread_tpp_change_priority") at assert.c:101

```

Signed-off-by: Ze Gan <[email protected]>
  • Loading branch information
Pterosaur committed Nov 28, 2023
1 parent 55a6828 commit 7472cb6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sonic-ycabled/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from setuptools import setup, find_packages
from distutils.command.build_ext import build_ext as _build_ext
import distutils.command
# The shared library of protobuf will be used in the swsscommon
# So, when we execute python setup.py test, the protobuf.so will be
# imported twice simultaneously in `GrpcTool run` and
# `test_y_cable_helper.py: from swsscommon import swsscommon`,
# The initialization of some global variables in protobuf.so will be conflicted
# so that raises an import error.
# To avoid this issue, we need to explicitly import swsscommon before
# above two steps.
from swsscommon import swsscommon

class GrpcTool(distutils.cmd.Command):
def initialize_options(self):
Expand Down

0 comments on commit 7472cb6

Please sign in to comment.