Skip to content
This repository
Browse code

[fix] remove the Py_NewInterpreter/Py_EndInterpreter hack since it se…

…emed to destabalize the windows build. Will put in a different work around.
  • Loading branch information...
commit 150611f81ddd099b0afdf2aee109750bdc26e695 1 parent 613af08
authored

Showing 1 changed file with 3 additions and 35 deletions. Show diff stats Hide diff stats

  1. 38  xbmc/interfaces/python/XBPyThread.cpp
38  xbmc/interfaces/python/XBPyThread.cpp
@@ -406,44 +406,12 @@ void XBPyThread::Process()
406 406
 
407 407
   Py_EndInterpreter(state);
408 408
 
409  
-  // This is a total hack. Python doesn't necessarily release
410  
-  // all of the objects associated with the interpreter when
411  
-  // you end the interpreter. As a result there are objects 
412  
-  // managed by the windowing system that still receive events
413  
-  // until python decides to clean them up. Python will eventually
414  
-  // clean them up on the creation or ending of a subsequent
415  
-  // interpreter. So we are going to keep creating and ending
416  
-  // interpreters until we have no more python objects hanging
417  
-  // around.
  409
+  // If we still have objects left around, produce an error message detailing what's been left behind
418 410
   if (languageHook->HasRegisteredAddonClasses())
419  
-  {
420  
-    CLog::Log(LOGDEBUG, "The python script \"%s\" has left several "
421  
-              "classes in memory that we will be attempting to clean up. The classes include: %s",
  411
+    CLog::Log(LOGWARNING, "The python script \"%s\" has left several "
  412
+              "classes in memory that we couldn't clean up. The classes include: %s",
422 413
               m_source, getListOfAddonClassesAsString(languageHook).c_str());
423 414
 
424  
-    int countLimit;
425  
-    for (countLimit = 0; languageHook->HasRegisteredAddonClasses() && countLimit < 100; countLimit++)
426  
-    {
427  
-      PyThreadState* tmpstate = Py_NewInterpreter();
428  
-      PyThreadState_Swap(tmpstate);
429  
-      if (PyRun_SimpleString(GC_SCRIPT) == -1)
430  
-        CLog::Log(LOGERROR,"Failed to run the gc to clean up after running %s",m_source);
431  
-      Py_EndInterpreter(tmpstate);
432  
-    }
433  
-
434  
-    // If necessary and successfull, debug log the results.
435  
-    if (countLimit > 0 && !languageHook->HasRegisteredAddonClasses())
436  
-      CLog::Log(LOGDEBUG,"It took %d Py_NewInterpreter/Py_EndInterpreter calls"
437  
-                " to clean up the classes leftover from running \"%s.\"",
438  
-                countLimit,m_source);
439  
-
440  
-    // If not successful, produce an error message detailing what's been left behind
441  
-    if (languageHook->HasRegisteredAddonClasses())
442  
-      CLog::Log(LOGERROR, "The python script \"%s\" has left several "
443  
-                "classes in memory that we couldn't clean up. The classes include: %s",
444  
-                m_source, getListOfAddonClassesAsString(languageHook).c_str());
445  
-  }
446  
-
447 415
   // unregister the language hook
448 416
   languageHook->UnregisterMe();
449 417
 

0 notes on commit 150611f

Please sign in to comment.
Something went wrong with that request. Please try again.