Browse Source

eliminate a bunch of sleeps, in one place use an Event to syncronize

tags/v0.1.0
John-Mark Gurney 5 years ago
parent
commit
2f8a62aa16
1 changed files with 4 additions and 14 deletions
  1. +4
    -14
      ntunnel.py

+ 4
- 14
ntunnel.py View File

@@ -518,8 +518,6 @@ class TestMain(unittest.TestCase):
badclientkeypath = os.path.join(self.tempdir, 'badclient_key')
await self.genkey(badclientkeypath)

await asyncio.sleep(.1)

# forwards connectsion to this socket (created by client)
ptclientpath = os.path.join(self.tempdir, 'incclient.sock')
ptclientstr = _makeunix(ptclientpath)
@@ -560,8 +558,6 @@ class TestMain(unittest.TestCase):
# wait for client to start
await _awaitfile(ptclientpath)

await asyncio.sleep(.1)

# Connect to the client
reader, writer = await connectsockstr(ptclientstr)

@@ -588,9 +584,6 @@ class TestMain(unittest.TestCase):
clientkeypath = os.path.join(self.tempdir, 'client_key')
await self.genkey(clientkeypath)

await asyncio.sleep(.1)
#import pdb; pdb.set_trace()

# forwards connectsion to this socket (created by client)
ptclientpath = os.path.join(self.tempdir, 'incclient.sock')
ptclientstr = _makeunix(ptclientpath)
@@ -633,8 +626,6 @@ class TestMain(unittest.TestCase):
# wait for client to start
await _awaitfile(ptclientpath)

await asyncio.sleep(.1)

# Connect to the client
reader, writer = await connectsockstr(ptclientstr)

@@ -781,8 +772,10 @@ class TestNoiseFowarder(unittest.TestCase):
# Setup pt target listener
pttarg = _makeunix(servptpath)
ptsock = []
ptsockevent = asyncio.Event()
def ptsockaccept(reader, writer, ptsock=ptsock):
ptsock.append((reader, writer))
ptsockevent.set()

# Bind to pt listener
lsock = await listensockstr(pttarg, ptsockaccept)
@@ -846,8 +839,8 @@ class TestNoiseFowarder(unittest.TestCase):
writer.write(enclenfun(encmsg))
writer.write(encmsg)

# XXX - how to sync?
await asyncio.sleep(.1)
# wait for the connection to arrive
await ptsockevent.wait()

ptreader, ptwriter = ptsock[0]
# read the test message
@@ -861,9 +854,6 @@ class TestNoiseFowarder(unittest.TestCase):
writer.write(enclenfun(encmsg))
writer.write(encmsg)

# XXX - how to sync?
await asyncio.sleep(.1)

# read the test message
rptmsg = await ptreader.readexactly(len(ptmsg))



Loading…
Cancel
Save