emulate defered

This commit is contained in:
Dmitriy Ryajov 2020-06-02 10:27:39 -06:00
parent 2ecc699b6e
commit a73bc40ae4
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 89 additions and 92 deletions

View File

@ -66,6 +66,7 @@ proc newStreamInternal*(m: Mplex,
method handle*(m: Mplex) {.async, gcsafe.} =
trace "starting mplex main loop", oid = m.oid
try:
try:
while not m.connection.closed:
trace "waiting for data", oid = m.oid
@ -157,11 +158,11 @@ method handle*(m: Mplex) {.async, gcsafe.} =
channoid = channel.oid,
oid = m.oid
break
except CatchableError as exc:
trace "Exception occurred", exception = exc.msg, oid = m.oid
finally:
trace "stopping mplex main loop", oid = m.oid
await m.close()
except CatchableError as exc:
trace "Exception occurred", exception = exc.msg, oid = m.oid
proc newMplex*(conn: Connection,
maxChanns: uint = MaxChannels): Mplex =

View File

@ -83,7 +83,6 @@ proc testPubSubDaemonPublish(gossip: bool = false,
let smsg = cast[string](data)
check smsg == pubsubData
times.inc()
echo "TIMES ", times
if times >= count and not finished:
finished = true
@ -108,7 +107,6 @@ proc testPubSubDaemonPublish(gossip: bool = false,
await wait(publisher(), 5.minutes) # should be plenty of time
echo "HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
result = true
await nativeNode.stop()
await allFutures(awaiters)
@ -144,7 +142,6 @@ proc testPubSubNodePublish(gossip: bool = false,
let smsg = cast[string](message.data)
check smsg == pubsubData
times.inc()
echo "TIMES ", times
if times >= count and not finished:
finished = true
result = true # don't cancel subscription
@ -356,7 +353,6 @@ suite "Interop":
check line == test
await conn.writeLp(cast[seq[byte]](test))
count.inc()
echo "COUNT ", count
testFuture.complete(count)
await conn.close()