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 segfault with protobuf, gym (atari), cv2, and ScenarIO #316

Merged
merged 1 commit into from
Mar 31, 2021
Merged
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
17 changes: 17 additions & 0 deletions bindings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ def preload_tensorflow_shared_libraries() -> None:
ctypes.CDLL(str(lib))


def pre_import_gym() -> None:

# Check if gym is installed
import importlib.util
spec = importlib.util.find_spec("gym")

if spec is None:
return

import gym


def import_gazebo() -> None:

# Check the the module was never loaded by someone else
Expand All @@ -85,6 +97,11 @@ def import_gazebo() -> None:
if os.environ.get("SCENARIO_DISABLE_TENSORFLOW_PRELOAD") != "1":
preload_tensorflow_shared_libraries()

# Import gym before scenario.bindings.gazebo. Similarly to tensorflow, also gym
# includes a module that imports protobuf, producing a similar segfault.
if os.environ.get("SCENARIO_DISABLE_GYM_PREIMPORT") != "1":
pre_import_gym()

# Import SWIG bindings
# See https://github.com/robotology/gym-ignition/issues/7
# https://stackoverflow.com/a/45473441/12150968
Expand Down