mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-13 13:20:07 +00:00
check the process id before disconnecting
This commit is contained in:
parent
5ae9a15eca
commit
ace34c4d08
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user