Resource temporarily unavailable when calling key.get_contents_to_filename

32 views
Skip to first unread message

aniket nanhe

unread,
Jan 6, 2015, 8:36:53 PM1/6/15
to boto-...@googlegroups.com
I wrote a simple program to test download requests from AIX machines. What I noticed was, when the program is running as a single thread and makes an http GET request, no matter how big the data transfer is, it succeeds.
Then I do the same thing under a child thread, making the parent thread wait for the child to complete. Now the child thread does a GET and tries to do recv() and fails after receiving a few hundred KB of data.
I am sure it has something to do with the system settings, since it works perfectly fine on Solaris and Linux boxes. Just can't figure out the what issue could be on AIX. Tried different values of 'Buffersize' in key.py but to no avail. 

Env:
Boto 2.34
Python 2.6

code:
def get_key():
    conn = connect(sys.argv[1])
    keyName = sys.argv[3]
    bucketName = sys.argv[2]
    
    bucket = conn.lookup(bucketName, validate=False)
    key = bucket.get_key(keyName, validate=False)
    key.get_contents_to_filename(sys.argv[4])
    
def get_key_main(): 
    get_key()

def get_key_thread(): 
    t = threading.Thread(target=get_key)
    t.daemon = False
    t.start()
    t.join()


if __name__ == '__main__':
    import timeit
    
    #Succeeds
    print(timeit.timeit("get_key_main()", setup="from __main__ import get_key_main", number=1))
    
    #Fails
    print(timeit.timeit("get_key_thread()", setup="from __main__ import get_key_thread", number=1))




Stack trace:

Traceback (most recent call last):
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/threading.py", line 527, in __bootstrap_inner
    self.run()
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/threading.py", line 479, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./key_get_docs.py", line 22, in get_key_thread
    key.get_contents_to_filename(sys.argv[4])
  File "/bb/bin/help/boto/s3/key.py", line 1710, in get_contents_to_filename
    response_headers=response_headers)
  File "/bb/bin/help/boto/s3/key.py", line 1648, in get_contents_to_file
    response_headers=response_headers)
  File "/bb/bin/help/boto/s3/key.py", line 1480, in get_file
    query_args=None)
  File "/bb/bin/help/boto/s3/key.py", line 1533, in _get_file_internal
    for bytes in self:
  File "/bb/bin/help/boto/s3/key.py", line 386, in next
    data = self.resp.read(self.BufferSize)
  File "/bb/bin/help/boto/connection.py", line 413, in read
    return http_client.HTTPResponse.read(self, amt)
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/httplib.py", line 537, in read
    s = self.fp.read(amt)
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/socket.py", line 351, in read
    data = self._sock.recv(left)
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/ssl.py", line 96, in <lambda>
    self.recv = lambda buflen=1024, flags=0: SSLSocket.recv(self, buflen, flags)
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/ssl.py", line 217, in recv
    return self.read(buflen)
  File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/ssl.py", line 136, in read
    return self._sslobj.read(len)
error: [Errno 11] Resource temporarily unavailable

Thanks
Aniket
Reply all
Reply to author
Forward
0 new messages