mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-16 15:25:12 +01:00
Fix race condition causing failed Travis builds #75.3 and #81.1.
This commit is contained in:
parent
bb1de5ca21
commit
38deda0d3b
@ -184,15 +184,16 @@ class Connection(object):
|
||||
Attempt to begin connecting to the server.
|
||||
May safely be called multiple times after the first, i.e. to reconnect.
|
||||
"""
|
||||
self.spawned = False
|
||||
with self._write_lock:
|
||||
# We hold the lock throughout, as connect() may be called by both
|
||||
# the network thread and a parent thread simultaneously, during
|
||||
# automatic version negotiation.
|
||||
|
||||
self.spawned = False
|
||||
self._outgoing_packet_queue = deque()
|
||||
|
||||
self._connect()
|
||||
self._handshake()
|
||||
|
||||
self.reactor = LoginReactor(self)
|
||||
self._start_network_thread()
|
||||
login_start_packet = packets.LoginStartPacket()
|
||||
if self.auth_token:
|
||||
login_start_packet.name = self.auth_token.profile.name
|
||||
@ -200,6 +201,9 @@ class Connection(object):
|
||||
login_start_packet.name = self.username
|
||||
self.write_packet(login_start_packet)
|
||||
|
||||
self.reactor = LoginReactor(self)
|
||||
self._start_network_thread()
|
||||
|
||||
def _connect(self):
|
||||
# Connect a socket to the server and create a file object from the
|
||||
# socket.
|
||||
|
Loading…
Reference in New Issue
Block a user