May 2019
Intermediate to advanced
542 pages
13h 37m
English
The HashRunner class will represent a single instance of the actual task that we're going to perform. For each file that we need to process, we'll create a unique HashRunner instance so its constructor will need to receive an input filename and an output filename as arguments. Its task will be to calculate the MD5 hash of the input file and append it along with the input filename to the output file.
We'll start it by subclassing QRunnable:
class HashRunner(qtc.QRunnable): file_lock = qtc.QMutex()
The first thing we do is create a QMutex object. In multithreading terminology, a mutex is an object shared between threads that can be locked or unlocked.
You can think of a mutex in the same way as the door of a single-user restroom ...
Read now
Unlock full access