Open
Description
Perhaps I am over-complicating things or missing some aspect of swift async that would make this work nicely.
However the present problem I have is that socket.once()
does not have a timeout nor can I get it to "cancel"
See below an example where I am trying to wrap socket.once() into swift async and use withCheckedContinuation
to safely wrap up the non swift async code but have no way to call the continuation after a timeout nor propagate the cancel downwards.
private func waitForPong(_ uuid: UUID, _ count: Int) async -> Bool {
let pongReceived = await withCheckedContinuation { continuation in
socket.once("pong") { _, _ in
continuation.resume(returning: true)
}
}
return pongReceived
}
If you create a task and have it await on waitForPong
it will wait indefinitely for that pong. Even if you cancel()
the there is no way to get rid of your now stuck Task.
Even if I off or cancel it I do not get the handler needed for the NormalCallback
Metadata
Metadata
Assignees
Labels
No labels