-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
status: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.
Description
Bug summary
matplotlib.get_backend()
will get stuck if DISPLAY
cannot be connected. Maybe should consider adding a timeout here.
matplotlib/src/_c_internal_utils.c
Lines 19 to 37 in 1b4b50b
if (getenv("DISPLAY") | |
&& (libX11 = dlopen("libX11.so.6", RTLD_LAZY))) { | |
struct Display* display = NULL; | |
struct Display* (* XOpenDisplay)(char const*) = | |
dlsym(libX11, "XOpenDisplay"); | |
int (* XCloseDisplay)(struct Display*) = | |
dlsym(libX11, "XCloseDisplay"); | |
if (XOpenDisplay && XCloseDisplay | |
&& (display = XOpenDisplay(NULL))) { | |
XCloseDisplay(display); | |
} | |
if (dlclose(libX11)) { | |
PyErr_SetString(PyExc_RuntimeError, dlerror()); | |
return NULL; | |
} | |
if (display) { | |
Py_RETURN_TRUE; | |
} | |
} |
Code for reproduction
import matplotlib
matplotlib.get_backend()
Actual outcome
get stuck
Expected outcome
return headless
if DISPLAY
cannot be connected
Additional information
No response
Operating system
No response
Matplotlib Version
3.7.3
Matplotlib Backend
No response
Python version
3.11.3
Jupyter version
No response
Installation
pip
Metadata
Metadata
Assignees
Labels
status: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.