Need to acquire the Python GIL also in ~PythonEventImpl, as it may be called at any time from the C++ code, from any thread.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Sat Sep 27 15:32:04 2008 +0100 (16 months ago)
changeset 372238ace50047e1
parent 3721 3748390f3608
child 3723 b663cbec7661
child 3726 d5a2890666e3
Need to acquire the Python GIL also in ~PythonEventImpl, as it may be called at any time from the C++ code, from any thread.
bindings/python/ns3module_helpers.cc
     1.1 --- a/bindings/python/ns3module_helpers.cc	Sat Sep 27 15:26:27 2008 +0100
     1.2 +++ b/bindings/python/ns3module_helpers.cc	Sat Sep 27 15:32:04 2008 +0100
     1.3 @@ -28,8 +28,14 @@
     1.4      }
     1.5      virtual ~PythonEventImpl ()
     1.6      {
     1.7 +        PyGILState_STATE __py_gil_state;
     1.8 +        __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
     1.9 +
    1.10          Py_DECREF(m_callback);
    1.11          Py_DECREF(m_args);
    1.12 +
    1.13 +        if (PyEval_ThreadsInitialized())
    1.14 +            PyGILState_Release(__py_gil_state);
    1.15      }
    1.16      virtual void Notify ()
    1.17      {