vavavr00m / boto

Automatically exported from code.google.com/p/boto
1 stars 0 forks source link

Boto is leaking sockets - CLOSE_WAIT -> "can't identify protocol" #412

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It seems as if boto is leaking sockets. lsof displays them as either 
"CLOSE_WAIT" or "can't identify protocol"

What steps will reproduce the problem?
1. Have boto retrieve an item from a domain all 5 minutes
2. Let it run for a couple of hours
3. Check "lsof -p [pid]"

What is the expected output? What do you see instead?

The expected output would be no sockets that are either in "CLOSE_WAIT" status 
or which are labelled as "can't identify protocol". But here they are:

$ lsof -p 28638
python  28638 ubuntu   16r  IPv4 399405      0t0    TCP 
domU-12-31-39-09-A5-F5.compute-1.internal:37105->72.21.207.139:https 
(CLOSE_WAIT)
python  28638 ubuntu   35r  sock    0,6      0t0 363204 can't identify protocol

Source code to reproduce this error:

import boto
import commands
from time import sleep, strftime
from os import getpid

domain = "YOUR_DOMAIN"
request_key = "YOUR_ITEM_KEY"
timeout = 60 * 5

pid = getpid()
sdb = boto.connect_sdb()
sdb_domain = sdb.get_domain(domain)

while True:
    item = sdb_domain.get_item(request_key)

    output  = commands.getstatusoutput("lsof -p %s | wc -l" % pid)[1]
    print strftime("[%Y-%m-%d %H:%m]"), "pid: %s, fd count: %s \t (details: 'lsof -p %s')" % (pid, o$

    # print item
    sleep(timeout)

I've had this error with SSL sockets before in other software projects. I could 
solve it only by using "origsock = sslsocket.unwrap(); origsock.close()"

Original issue reported on code.google.com by metaka...@gmail.com on 13 Jul 2010 at 1:42

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It seems this is actually an issue with httplib.HTTPSConnection which doesn't 
properly close the sockets after the timeout.

Original comment by metaka...@gmail.com on 13 Jul 2010 at 2:52

GoogleCodeExporter commented 9 years ago
So, is there anything that can be done at the boto level to help?

Original comment by Mitch.Ga...@gmail.com on 19 Jul 2010 at 11:01

GoogleCodeExporter commented 9 years ago
I believe not. I think we should contact the httplib.HTTPSConnection maintainer 
about that issue.

Original comment by metaka...@gmail.com on 19 Jul 2010 at 11:07