Remove unnecessary async (#836)

This commit is contained in:
diegomrsantos 2023-01-05 15:02:52 +01:00 committed by GitHub
parent 5e3323d43f
commit e304ad0f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -416,7 +416,7 @@ proc getIncomingSlot*(c: ConnManager): Future[ConnectionSlot] {.async.} =
await c.inSema.acquire()
return ConnectionSlot(connManager: c, direction: In)
proc getOutgoingSlot*(c: ConnManager, forceDial = false): Future[ConnectionSlot] {.async.} =
proc getOutgoingSlot*(c: ConnManager, forceDial = false): ConnectionSlot {.raises: [Defect, TooManyConnectionsError].} =
if forceDial:
c.outSema.forceAcquire()
elif not c.outSema.tryAcquire():

View File

@ -177,7 +177,7 @@ proc internalConnect(
trace "Reusing existing connection", conn, direction = $conn.dir
return conn
let slot = await self.connManager.getOutgoingSlot(forceDial)
let slot = self.connManager.getOutgoingSlot(forceDial)
conn =
try:
await self.dialAndUpgrade(peerId, addrs)

View File

@ -259,11 +259,11 @@ suite "Connection Manager":
let connMngr = ConnManager.new(maxConnections = 3)
for i in 0..<3:
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
discard connMngr.getOutgoingSlot()
# should throw adding a connection over the limit
expect TooManyConnectionsError:
discard await connMngr.getOutgoingSlot()
discard connMngr.getOutgoingSlot()
await connMngr.close()
@ -271,7 +271,7 @@ suite "Connection Manager":
let connMngr = ConnManager.new(maxConnections = 3)
for i in 0..<3:
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
discard connMngr.getOutgoingSlot()
# should timeout adding a connection over the limit
check not(await connMngr.getIncomingSlot().withTimeout(10.millis))
@ -286,7 +286,7 @@ suite "Connection Manager":
# should throw adding a connection over the limit
expect TooManyConnectionsError:
discard await connMngr.getOutgoingSlot()
discard connMngr.getOutgoingSlot()
await connMngr.close()
@ -304,11 +304,11 @@ suite "Connection Manager":
let connMngr = ConnManager.new(maxOut = 3)
for i in 0..<3:
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
discard connMngr.getOutgoingSlot()
# should throw adding a connection over the limit
expect TooManyConnectionsError:
discard await connMngr.getOutgoingSlot()
discard connMngr.getOutgoingSlot()
await connMngr.close()
@ -316,7 +316,7 @@ suite "Connection Manager":
let connMngr = ConnManager.new(maxOut = 3)
for i in 0..<3:
check await connMngr.getOutgoingSlot().withTimeout(10.millis)
discard connMngr.getOutgoingSlot()
# should timeout adding a connection over the limit
check not(await connMngr.getIncomingSlot().withTimeout(10.millis))
@ -332,7 +332,7 @@ suite "Connection Manager":
# should throw adding a connection over the limit
expect TooManyConnectionsError:
discard await connMngr.getOutgoingSlot()
discard connMngr.getOutgoingSlot()
await connMngr.close()
@ -341,11 +341,11 @@ suite "Connection Manager":
var conns: seq[Connection]
for i in 0..<3:
check await connMngr.getOutgoingSlot(true).withTimeout(10.millis)
discard connMngr.getOutgoingSlot(true)
# should throw adding a connection over the limit
expect TooManyConnectionsError:
discard await connMngr.getOutgoingSlot(false)
discard connMngr.getOutgoingSlot(false)
await connMngr.close()
@ -354,7 +354,7 @@ suite "Connection Manager":
var conns: seq[Connection]
for i in 0..<3:
let slot = await ((connMngr.getOutgoingSlot()).wait(10.millis))
let slot = connMngr.getOutgoingSlot()
let conn =
getConnection(