thread with args python

dRecieved = connFile.readline()
processThread = threading.Thread(target=processLine, args=(dRecieved,))  # <- note extra ','
processThread.start()

Here is what the above code is Doing:
1. It's creating a threading.Thread object, and passing it the function processLine and the tuple ('dRecieved',).
2. It's calling the start() method on the thread object.
3. It's calling the readline() method on the connFile object.
4. It's calling the join() method on the thread object.

The join() method is important. It tells the main thread to wait until the processLine thread is done before continuing.

If you don't call join(), the main thread will continue on to the next line of the file, and the processLine thread will be left behind.

The processLine thread will eventually catch up, but it will be working on the wrong line of the file.

The join() method is a blocking call. That means it will wait until the processLine thread is done before it returns.

If you want the main thread to continue on its way without waiting for the processLine thread to finish, you can pass the join() method a timeout argument.

For example, this code will wait up to 5 seconds for the processLine thread to finish before continuing on:

processThread.join(5)

If the processLine thread is still running after 5 seconds, the main thread will continue on its way.

The processLine thread will keep running in the background, but it will be working on the wrong line of the file.

If you want the main thread to continue on its way without waiting for the processLine thread to finish, you can pass the join() method a timeout argument.

For example, this code will wait up to 5 seconds for the processLine thread to finish before continuing on:

processThread.join(5)

If the processLine thread is still running after 5 seconds, the main thread will continue on its way.

The processLine thread will keep running in the background, but it will be working on the wrong line of the file.