擅长:python、mysql、java
<p>你可以使用线程。你知道吗</p>
<p>代码:</p>
<pre><code>import threading
success = False
def connect():
global success
connection(server,5)
success = True
th = threading.Thread(target=connect)
th.start()
time.sleep(5) #timeout 5 sec
if success:
yuhuuu
else:
th.stop() #kill task
</code></pre>