check the process id before disconnecting

This commit is contained in:
cadop 2021-04-27 19:33:37 -04:00
parent 5ae9a15eca
commit ace34c4d08

View File

@ -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