You can run the function 1 and 2 in two separate threads.
from threading import Thread
t1 = Thread(target = function1)
t2 = Thread(target = function2)
t1.setDaemon(True)
t2.setDaemon(True)
t1.start()
<your code to connect to server>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…