Browse Source

task: Fix memory leak related to Python 3 signal API changes

Python 3's signal.py API does not properly support custom signal handlers. An exception is created every frame because of this, which fills up the memory of the application.

Closes #873
Derzsi Dániel 5 years ago
parent
commit
eccfce4606
1 changed files with 5 additions and 1 deletions
  1. 5 1
      direct/src/task/Task.py

+ 5 - 1
direct/src/task/Task.py

@@ -17,9 +17,13 @@ from direct.showbase.MessengerGlobal import messenger
 import types
 import types
 import random
 import random
 import importlib
 import importlib
+import sys
 
 
 try:
 try:
-    import signal
+    if sys.version_info >= (3, 0):
+        import _signal as signal
+    else:
+        import signal
 except ImportError:
 except ImportError:
     signal = None
     signal = None