Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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