[zeromq-dev] successive connect/disconnect fails after a while
Boaz Kelmer
Boaz.Kelmer at twosigma.com
Thu Aug 22 23:05:21 CEST 2013
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()
More information about the zeromq-dev
mailing list