I implemented a paho-mqtt client to do a specific task when a message arrives. Therefore I use the on_message callback function like that:
def on_message():