mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-02-26 19:40:32 +00:00
emulate defered
This commit is contained in:
parent
2ecc699b6e
commit
a73bc40ae4
@ -66,6 +66,7 @@ proc newStreamInternal*(m: Mplex,
|
|||||||
|
|
||||||
method handle*(m: Mplex) {.async, gcsafe.} =
|
method handle*(m: Mplex) {.async, gcsafe.} =
|
||||||
trace "starting mplex main loop", oid = m.oid
|
trace "starting mplex main loop", oid = m.oid
|
||||||
|
try:
|
||||||
try:
|
try:
|
||||||
while not m.connection.closed:
|
while not m.connection.closed:
|
||||||
trace "waiting for data", oid = m.oid
|
trace "waiting for data", oid = m.oid
|
||||||
@ -157,11 +158,11 @@ method handle*(m: Mplex) {.async, gcsafe.} =
|
|||||||
channoid = channel.oid,
|
channoid = channel.oid,
|
||||||
oid = m.oid
|
oid = m.oid
|
||||||
break
|
break
|
||||||
except CatchableError as exc:
|
|
||||||
trace "Exception occurred", exception = exc.msg, oid = m.oid
|
|
||||||
finally:
|
finally:
|
||||||
trace "stopping mplex main loop", oid = m.oid
|
trace "stopping mplex main loop", oid = m.oid
|
||||||
await m.close()
|
await m.close()
|
||||||
|
except CatchableError as exc:
|
||||||
|
trace "Exception occurred", exception = exc.msg, oid = m.oid
|
||||||
|
|
||||||
proc newMplex*(conn: Connection,
|
proc newMplex*(conn: Connection,
|
||||||
maxChanns: uint = MaxChannels): Mplex =
|
maxChanns: uint = MaxChannels): Mplex =
|
||||||
|
@ -83,7 +83,6 @@ proc testPubSubDaemonPublish(gossip: bool = false,
|
|||||||
let smsg = cast[string](data)
|
let smsg = cast[string](data)
|
||||||
check smsg == pubsubData
|
check smsg == pubsubData
|
||||||
times.inc()
|
times.inc()
|
||||||
echo "TIMES ", times
|
|
||||||
if times >= count and not finished:
|
if times >= count and not finished:
|
||||||
finished = true
|
finished = true
|
||||||
|
|
||||||
@ -108,7 +107,6 @@ proc testPubSubDaemonPublish(gossip: bool = false,
|
|||||||
|
|
||||||
await wait(publisher(), 5.minutes) # should be plenty of time
|
await wait(publisher(), 5.minutes) # should be plenty of time
|
||||||
|
|
||||||
echo "HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
|
||||||
result = true
|
result = true
|
||||||
await nativeNode.stop()
|
await nativeNode.stop()
|
||||||
await allFutures(awaiters)
|
await allFutures(awaiters)
|
||||||
@ -144,7 +142,6 @@ proc testPubSubNodePublish(gossip: bool = false,
|
|||||||
let smsg = cast[string](message.data)
|
let smsg = cast[string](message.data)
|
||||||
check smsg == pubsubData
|
check smsg == pubsubData
|
||||||
times.inc()
|
times.inc()
|
||||||
echo "TIMES ", times
|
|
||||||
if times >= count and not finished:
|
if times >= count and not finished:
|
||||||
finished = true
|
finished = true
|
||||||
result = true # don't cancel subscription
|
result = true # don't cancel subscription
|
||||||
@ -356,7 +353,6 @@ suite "Interop":
|
|||||||
check line == test
|
check line == test
|
||||||
await conn.writeLp(cast[seq[byte]](test))
|
await conn.writeLp(cast[seq[byte]](test))
|
||||||
count.inc()
|
count.inc()
|
||||||
echo "COUNT ", count
|
|
||||||
|
|
||||||
testFuture.complete(count)
|
testFuture.complete(count)
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user