Skip to content

Instantly share code, notes, and snippets.

@argosopentech
Created October 29, 2020 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save argosopentech/326008095f2cd726d9567e171fcf3842 to your computer and use it in GitHub Desktop.
Save argosopentech/326008095f2cd726d9567e171fcf3842 to your computer and use it in GitHub Desktop.
Memory Leak in Python with PyQt and OpenNMT CTranslate
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtCore import QThread
import ctranslate2
class WorkerThread(QThread):
def __del__(self):
self.wait()
def run(self):
translator = ctranslate2.Translator('/path/to/ctranslate/model')
class GUIWindow(QMainWindow):
def translate(self):
new_worker_thread = WorkerThread()
new_worker_thread.start()
app = QApplication([])
main_window = GUIWindow()
main_window.show()
for i in range(120):
print(i)
main_window.translate()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment