私は次のコードを持っています:
s.settimeout( 300 )
while notend:
data = s.recv()
datacheck()
...
上記のコードはスレッド上で実行されているため、ユーザーがnotend
変数をFalseに設定すると、スレッドは終了します。ただし、この場合、すぐには終了しませんrecv
。関数のため、終了するのに300秒かかります。このスレッドを終了するにはどうすればよいですか?
# Wait all the threads
for thread in threading.enumerate():
if thread is not threading.currentThread():
thread.join()