We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I call socket.receiveString() in a Venice Coroutine, the app blocks inside the coroutine.
socket.receiveString()
Example When I run the following code, it prints running coroutine and then blocks.
running coroutine
import ZeroMQ import Venice let context = try Context() let inbound = try context.socket(.Pull) try inbound.bind("tcp://127.0.0.1:5555") co { print("running coroutine") do { while let data = try inbound.receiveString() where data != "Bye!" { print(data) } } catch { print("An error occured") } } print("sending messages outside the coroutine") let outbound = try context.socket(.Push) try outbound.connect("tcp://127.0.0.1:5555") try outbound.sendString("Hello World!") try outbound.sendString("Bye!")
Am I using Venice wrong or is this a bug?
The text was updated successfully, but these errors were encountered:
@Dev1an Because in example above it don't used venice polling. So it's blocks a thread. To avoid this you should use Venice.poll E.g.
public class ZmqConnection { let socket: ZeroMQ.Socket let address: String var polled: Venice.PollEvent? = nil var fd: Int32 { return try! socket.getFileDescriptor() } init(address: String, type: SocketType) { self.address = address socket = try! context.socket(type) } public func connect() throws { try socket.connect(address) } func read() -> [Data]? { if polled == nil { polled = try! Venice.poll(fd, for: .reading) guard polled!.contains(.reading) else { return nil } } let events = try! socket.getEvents()! if events.contains(.In) { var msg_parts: [Data] = [] while true { guard let array = try! socket.receive() else { break } msg_parts.append(array) if !(try! socket.getReceiveMore()) { break } } return msg_parts } else { polled = nil return nil } } }
But I'm not sure it's works 100%
Sorry, something went wrong.
No branches or pull requests
When I call
socket.receiveString()
in a Venice Coroutine, the app blocks inside the coroutine.Example
When I run the following code, it prints
running coroutine
and then blocks.Am I using Venice wrong or is this a bug?
The text was updated successfully, but these errors were encountered: