Fix ogl test hang

Summary: See https://github.com/facebookresearch/pytorch3d/issues/1908

Reviewed By: MichaelRamamonjisoa

Differential Revision: D65280253

fbshipit-source-id: ec05902c5f2f7eb9ddd92bda0045cc3564b8c091
This commit is contained in:
Jeremy Reizenstein 2024-11-06 11:40:42 -08:00 committed by Facebook GitHub Bot
parent 8fe6934885
commit 81d82980bc

View File

@ -184,7 +184,7 @@ class EGLContext:
"""
# Lock used to prevent multiple threads from rendering on the same device
# at the same time, creating/destroying contexts at the same time, etc.
self.lock = threading.Lock()
self.lock = threading.RLock()
self.cuda_device_id = cuda_device_id
self.device = _get_cuda_device(self.cuda_device_id)
self.width = width
@ -224,15 +224,14 @@ class EGLContext:
Throws:
EGLError when the context cannot be made current or make non-current.
"""
self.lock.acquire()
egl.eglMakeCurrent(self.dpy, self.surface, self.surface, self.context)
try:
yield
finally:
egl.eglMakeCurrent(
self.dpy, egl.EGL_NO_SURFACE, egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT
)
self.lock.release()
with self.lock:
egl.eglMakeCurrent(self.dpy, self.surface, self.surface, self.context)
try:
yield
finally:
egl.eglMakeCurrent(
self.dpy, egl.EGL_NO_SURFACE, egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT
)
def get_context_info(self) -> Dict[str, Any]:
"""