请求中的python-swiftclient断管

时间:2014-06-20 12:25:13

标签: python python-requests openstack-swift

我正在尝试将python-swiftclient合并到我笨拙的API中,但我遇到了一些麻烦。这是最简单的剥离代码:

import swiftclient

url = "url-goes-here"
user = "my-user-goes-here"
key = "my-key-goes-here"

def get_token():
    return swiftclient.get_auth(url, user, key)[1]

def upload():
    theFile = open("/home/ivica/thefile.pdf", 'rb')
    token = get_token()

    resp = swiftclient.put_object(url,token,'test6','some name.pdf',theFile)

    print resp

upl()

文件正在上传约30秒,然后弹出此错误:

File "/usr/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 372, in send
    raise ConnectionError(sockerr, request=request)
requests.exceptions.ConnectionError: [Errno 32] Broken pipe

0 个答案:

没有答案