[英]twisted with zmq giving strange error
i am using twisted with zmq . 我正在用zmq扭曲。 here is an overview of application :
这是应用程序概述:
i have two twisted instances running on two systems and i am using zmq(txZmq)
for message passing. 我有两个在两个系统上运行的扭曲实例,并且我正在使用
zmq(txZmq)
进行消息传递。
systemA
submits some jobs to be processed by systemB
.and after job is finished it has to notify systemA
(for some imp reasons). systemA
提交了一些要由系统systemB
处理的作业。完成作业后,它必须通知系统systemA
(出于某些systemA
原因)。 so on both systems i am having zmq
listen as well as send messages using different ports. 所以在两个系统上,我都有
zmq
侦听以及使用不同的端口发送消息。 now i am getting error : zmq.error.Again: Resource temporarily unavailable
it might be because when the reactor on systemA
is processing some data systemB happens to send a notification message(which is part of my application) to systemA
on which zmq
was also listening for incoming messages. 现在我收到错误消息:
zmq.error.Again: Resource temporarily unavailable
这可能是因为当systemA
上的systemA
正在处理某些数据时,systemB恰巧将通知消息(这是我的应用程序的一部分)发送到了zmq
所在的systemA
监听传入的消息。
so i changed the processing part on systemA
to a twisted thread using callInThread
also inside thread i am sending message to zmq but again i am getting the same error zmq.error.Again: Resource temporarily unavailable
所以我在线程内也使用
callInThread
将callInThread
上的处理部分systemA
为扭曲线程,我正在向zmq发送消息,但再次出现相同的错误zmq.error.Again: Resource temporarily unavailable
why is it so??? 为什么会这样??? code is something like this:
代码是这样的:
def send_remote_job():
# do some computation like fetch from db and process then send
send_socket.push(dumps(job_data))
recieve_socket.onPull = listen_for_notifiction()
reactor.callInThread(send_remote_job)
reactor.run()
Hmmm, I don't know anything at all about Twisted, but 嗯,我对“扭曲”一无所知,但是
it might be because when the reactor on systemA is processing some data systemB happens to send a notification message(which is part of my application) to systemA on which zmq was also listening for incoming messages.
可能是因为当systemA上的反应堆正在处理某些数据时,systemB恰巧向systemA发送了一条通知消息(这是我的应用程序的一部分),而zmq也在该通知消息上监听传入的消息。
doesn't sound right. 听起来不对。 ZeroMQ implements the Actor model of programming, in which messages get queued up (on the sender, in the network itself, and at the receiver) and are transferred as and when connectivity permits.
ZeroMQ实现了Actor编程模型,在该模型中,消息被排队(在发送方,网络本身以及接收方),并在连接允许时进行传输。 Thus there is no rendevous implicit in sending and recieving a message in ZeroMQ.
因此,在ZeroMQ中发送和接收消息时没有任何隐含的隐忧。 So, even if SystemA were busy doing something else at the point when SystemB sends its notification, that will not cause any problems.
因此,即使SystemA在SystemB发送其通知时正在忙于做其他事情,也不会造成任何问题。
zmq.Error.Again sounds like EAGAIN wrapped up nicely for Pythonesque reasons. 同样,由于Python风格的原因,zmq.Error.Again听起来很像EAGAIN。 This is returned by zmq_send() if a message were sent with the ZMQ_DONTWAIT flag set but, for some reason or other, the message could not be sent.
如果发送的消息设置了ZMQ_DONTWAIT标志,则zmq_send()返回此消息,但是由于某种原因,该消息无法发送。 Possible reasons include (but are not limited) to:
可能的原因包括(但不限于):
General Note 一般说明
ZMQ doesn't guarantee message delivery. ZMQ不保证消息传递。 A successful zmq_send merely means that a message has been queued for sending.
成功的zmq_send仅意味着已将消息排队等待发送。
If the conditions (ie the socket is connected and receiver is actually calling zmq_recv) are correct the message will get transferred either whole, or not at all. 如果条件(即套接字已连接,并且接收方实际上正在调用zmq_recv)是正确的,则消息将全部传输或完全不传输。 Nothing partial.
没有偏见。
This is in contrast to, say, a Communicating Sequential Processes environment where a message cannot be sent unless the recipient is ready and waiting to receive the message. 例如,这与“通信顺序过程”环境相反,在该环境中,除非收件人准备好并等待接收消息,否则无法发送消息。 Thus with CSP, when a message is sent you know that it was received - a rendevous.
因此,使用CSP,发送消息时,您就知道它已被接收-太糟了。 This is much nicer in environments where one has to worry about fault tolerance / recovery / etc.
在人们不得不担心容错/恢复等的环境中,这要好得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.