[nanomsg] SURVEYOR protocol, why sleep is needed?

  • From: Matias Guijarro <matias.guijarro@xxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Fri, 24 Apr 2015 09:40:20 +0200

Hi all,

This is my first post on the list, so first of all thanks a lot
for nanomsg: it really rocks ! :D

I have got a question about an odd behaviour I remarked. I am
using the SURVEYOR scalability protocol in a Python application
(using nanomsg-python, the more popular Python binding).

I have a group of respondents, all of them bind to a tcp address ;
then, my surveyor is connecting to each one and is making the
request.

Here is a short code example of what I am doing:

s = nanomsg.Socket(nanomsg.SURVEYOR)
for respondent in respondent_address_list:
s.connect(respondent)
###
time.sleep(0.1)
###
s.send("my request")
...
data = s.recv()
...

Without the "time.sleep" delay, send seems to work fine but the
receive call returns an invalid state exception.

I wonder why is the "sleep" necessary ?

I tried with nanocat, again I need to set a delay otherwise it
doesn't work neither.

I would be very happy if someone could explain why it is needed.

Which value should I put ? 100 ms seems a lot, I can maybe reduce
it ? What is the criteria to find the smallest value ?

Thanks a lot in advance,
Matias.












Other related posts: