mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-16 07:15:24 +01:00
Add thread timeout detection to test_connection.
This commit is contained in:
parent
9af39f186a
commit
abd2ee774c
@ -10,12 +10,12 @@ from future.utils import raise_
|
|||||||
import unittest
|
import unittest
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
import random
|
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
VERSIONS = sorted(SUPPORTED_MINECRAFT_VERSIONS.items(), key=lambda i: i[1])
|
VERSIONS = sorted(SUPPORTED_MINECRAFT_VERSIONS.items(), key=lambda i: i[1])
|
||||||
|
THREAD_TIMEOUT_S = 5
|
||||||
|
|
||||||
|
|
||||||
class _ConnectTest(unittest.TestCase):
|
class _ConnectTest(unittest.TestCase):
|
||||||
@ -47,7 +47,9 @@ class _ConnectTest(unittest.TestCase):
|
|||||||
# Wait for all threads to exit.
|
# Wait for all threads to exit.
|
||||||
for thread in server_thread, client_thread:
|
for thread in server_thread, client_thread:
|
||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
thread.join()
|
thread.join(THREAD_TIMEOUT_S)
|
||||||
|
if thread.is_alive():
|
||||||
|
self.fail('Thread "%s" timed out.' % thread.name)
|
||||||
|
|
||||||
def _test_connect_client(self, client, cond):
|
def _test_connect_client(self, client, cond):
|
||||||
def handle_packet(packet):
|
def handle_packet(packet):
|
||||||
|
Loading…
Reference in New Issue
Block a user