From ace34c4d08e199f475f30e665942395de69d35f7 Mon Sep 17 00:00:00 2001 From: cadop Date: Tue, 27 Apr 2021 19:33:37 -0400 Subject: [PATCH] check the process id before disconnecting --- examples/pybullet/gym/pybullet_utils/bullet_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/pybullet/gym/pybullet_utils/bullet_client.py b/examples/pybullet/gym/pybullet_utils/bullet_client.py index 6543313d0..6703722ff 100644 --- a/examples/pybullet/gym/pybullet_utils/bullet_client.py +++ b/examples/pybullet/gym/pybullet_utils/bullet_client.py @@ -1,6 +1,7 @@ """A wrapper for pybullet to manage different clients.""" from __future__ import absolute_import from __future__ import division +import os import functools import inspect import pybullet @@ -21,6 +22,7 @@ class BulletClient(object): `pybullet.SHARED_MEMORY` connects to an existing simulation. """ self._shapes = {} + self._pid = os.getpid() if connection_mode is None: self._client = pybullet.connect(pybullet.SHARED_MEMORY, options=options) if self._client >= 0: @@ -34,7 +36,7 @@ class BulletClient(object): def __del__(self): """Clean up connection if not already done.""" - if self._client>=0: + if self._client>=0 and self._pid == os.getpid(): try: pybullet.disconnect(physicsClientId=self._client) self._client = -1