Created
October 14, 2013 18:30
-
-
Save tkanerva/6979907 to your computer and use it in GitHub Desktop.
jython 2.7b2+ ends up with exhausting all file descriptors (ulimit=1024)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import subprocess | |
>>> def ping(addr): | |
... cmd1 = '/bin/ping -c2 {addr}'.format(addr=addr) | |
... try: | |
... output = subprocess.check_output(cmd1.split(' ')) | |
... except subprocess.CalledProcessError: | |
... retval = False | |
... min = 0 | |
... else: | |
... head, _, rest = output.partition('mdev =') | |
... min, avg, max, mdev = rest[:-4].split('/') | |
... received = head.partition('packets transmitted,')[2][:2] | |
... retval = True if int(received) > 0 else False | |
... return (retval, float(min)) | |
... | |
>>> a1='8.8.8.8' | |
>>> lst=[] | |
>>> for i in range(1024): | |
... lst.append( ping(a1) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment