diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2018-10-06 11:13:18 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2018-10-06 11:13:18 (GMT) | 
| commit | ce8523394ea49b91228e6f05a738d72d14b2e5c1 (patch) | |
| tree | 2bc879544da39b7e91005c15f8e34208ba6a30cf /plugins | |
| parent | 39d9bf72c549b2b601e9c78aca7a855cd5af9162 (diff) | |
Dealt with the Python global lock at exit.
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/pychrysalide/plugin.c | 24 | 
1 files changed, 20 insertions, 4 deletions
| diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c index 321fda9..c42235a 100644 --- a/plugins/pychrysalide/plugin.c +++ b/plugins/pychrysalide/plugin.c @@ -164,14 +164,30 @@ static void g_python_plugin_init(GPythonPlugin *plugin)  static void g_python_plugin_dispose(GPythonPlugin *plugin)  { -    PyGILState_STATE gstate;                /* Sauvegarde d'environnement  */ - -    gstate = PyGILState_Ensure(); +    PyThreadState *tstate;                  /* Contexte d'environnement    */ + +    /** +     * Cf. https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock +     * +     * Cependant, comme on se trouve à priori dans le thread principal de l'interpréteur, +     * PyGILState_Ensure() ne pose aucun verrou. Ce qui aboutit à la situation suivante : +     * +     *    Fatal Python error: drop_gil: GIL is not locked +     * +     * On peut forcer les choses avec PyEval_AcquireLock(), mais cette fonction est marquée +     * comme dépréciée depuis Python 3.2. +     * +     * Donc on choisit les alternatives officielles. +     */ + +    tstate = PyThreadState_Get(); + +    PyEval_RestoreThread(tstate);      Py_XDECREF(plugin->instance);      plugin->instance = NULL; -    PyGILState_Release(gstate); +    PyEval_SaveThread();      G_OBJECT_CLASS(g_python_plugin_parent_class)->dispose(G_OBJECT(plugin)); | 
