I have to build a simple program using pyqt5 that prints a random number in a `lineEdit` box. To start the program we have to click on `Run` pushbutton. Every three seconds a new random number is generated and we reprint it. 

However, the program seems blocked due to the *3 seconds hold period* function. I'm using the `partial` function defined in `functools` to run this process in the background, but it is not running properly.

A print screen of the program, as well as the code, is shown below:

[![enter image description here](https://i.stack.imgur.com/RPCGm.png)](https://i.stack.imgur.com/RPCGm.png)

```
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
import numpy as np
import time
from functools import partial

class RandomGen(object):
    number = None
    def run(self, lineEdit):
        while True:
             self.number = np.random.rand()
             lineEdit.setText("XXX")
             print(self.number)
             time.sleep(3);

class Ui_Dialog(object):
    counter_val = 0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(321, 220)

        self.lineEdit = QtWidgets.QLineEdit(Dialog)
        self.lineEdit.setGeometry(QtCore.QRect(100, 30, 113, 21))
        self.lineEdit.setObjectName("lineEdit")

        self.lineEdit = QtWidgets.QLineEdit(Dialog)
        self.lineEdit.setGeometry(QtCore.QRect(100, 70, 113, 21))
        self.lineEdit.setObjectName("lineEdit")

        self.pushButton = QtWidgets.QPushButton(Dialog)
        self.pushButton.setGeometry(QtCore.QRect(100, 110, 113, 32))
        self.pushButton.setObjectName("pushButton")

        self.pushButton2 = QtWidgets.QPushButton(Dialog)
        self.pushButton2.setGeometry(QtCore.QRect(100, 160, 113, 32))
        self.pushButton2.setObjectName("pushButton")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
        self.pushButton.setText(_translate("Dialog", "Run"))
        self.pushButton2.setText(_translate("Dialog", "Counter"))

        self.pushButton.clicked.connect(partial(self.runner))
        self.pushButton2.clicked.connect(self.counter)

    def runner(self):
        rand = RandomGen()
        rand.run(self.lineEdit)

    def counter(self):
        self.lineEdit.setText(str(self.counter_val))
        self.counter_val = self.counter_val + 1

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())

```