Created
October 29, 2020 02:10
-
-
Save argosopentech/326008095f2cd726d9567e171fcf3842 to your computer and use it in GitHub Desktop.
Memory Leak in Python with PyQt and OpenNMT CTranslate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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