[zeromq-dev] successive connect/disconnect fails after a while
Matt Connolly
matt.connolly at me.com
Fri Aug 23 03:09:57 CEST 2013
My understanding is that connections are created asynchronously in a background thread, and that file descriptors are used to communicate between your threads and the zeromq io threads.
Does it do the same thing if you put a sleep in there, giving the zeromq io thread time to close the file descriptors?
-Matt
On 23 Aug 2013, at 7:05 am, Boaz Kelmer <Boaz.Kelmer at twosigma.com> wrote:
>
> Many attempts to connect()/disconnect() will eventually fail with EINVAL.
> It seems that the number of successful connect()/disconnect() pairs is somewhat correlated
> with the number of allowed open file descriptors for the process, as if some descriptors are
> not closed:
>
> $ python dis.py
> RLIMIT_NOFILE: soft=100, hard=200000
> 4623: Error: Invalid argument
>
> $ cat dis.py
>
> import sys
> import socket
> import resource
> import zmq
>
> def main():
> ctx = zmq.Context()
> s = ctx.socket(zmq.SUB)
> s.setsockopt(zmq.SUBSCRIBE, "")
> addr = "tcp://%s:6666" % socket.gethostname()
> soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
> resource.setrlimit(resource.RLIMIT_NOFILE, (100, hard))
> soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
> print "RLIMIT_NOFILE: soft=%s, hard=%s" % (soft, hard)
> for i in xrange(1000000):
> try:
> s.connect(addr)
> s.disconnect(addr)
> except Exception as ex:
> print >> sys.stderr, "%d: Error: %s" % (i, ex)
> return
>
> if __name__ == '__main__':
> main()
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list