def run_in_thread(fn, args):
    worker = Worker(*args)
    worker.process = fn
    thread = QThread()
    worker.moveToThread(thread)
    app = QApplication.instance()
    app.connect(thread, Qt.SIGNAL('started()'), worker.start)
    app.connect(worker, Qt.SIGNAL('finished()'), thread.quit)
    app.connect(worker, Qt.SIGNAL('finished()'), thread.deleteLater)
    return worker, thread