GithubHelp home page GithubHelp logo

Comments (17)

longbai avatar longbai commented on July 17, 2024

@shuaishuai 收到,我们来看下

from python-sdk.

philiptzou avatar philiptzou commented on July 17, 2024

不赞成用ret+err处理一切异常,把处理不了的错误raise出来给外界catch才是pythonic的做法啊

from python-sdk.

hbrls avatar hbrls commented on July 17, 2024

@philiptzou 如果我没理解错的话,ret, err是go的做法吧

from python-sdk.

philiptzou avatar philiptzou commented on July 17, 2024

@shuaishuai 是的

Python偏好先做再看(EAFP,It is Easier to Ask for Forgiveness than Permission)原则,所以鼓励用异常;Go正好相反,为避免对流程控制造成混乱而极力不鼓励用异常

http://www.reddit.com/r/Python/comments/1qrizj/do_your_raise_exceptions_or_return_errors_as_part/

https://en.wikipedia.org/wiki/Python_syntax_and_semantics#Exceptions

from python-sdk.

hbrls avatar hbrls commented on July 17, 2024

出错太频繁了,受不了了,用try except

from python-sdk.

longbai avatar longbai commented on July 17, 2024

@shuaishuai 请问您说的出错太频繁是什么错误?

from python-sdk.

hbrls avatar hbrls commented on July 17, 2024

@longbai 应用场景是我需要把log文件传到七牛,一个文件一个文件的传,比如传好access.log.1,接着传access.log.2,类推。大约30%左右会传失败,就是上面这个BadStatusLine错误,随机遇到,没有特征。我是在for循环里面跑的,如果不用try except,那么脚本就会挂掉。

from python-sdk.

philiptzou avatar philiptzou commented on July 17, 2024

貌似我也遇到这个问题了……

from python-sdk.

philiptzou avatar philiptzou commented on July 17, 2024

搞出来了个bugdemo,貌似是在批处理之后再请求就会崩掉:

# -*- coding: utf-8 -*-

import qiniu.auth.digest

mac = qiniu.auth.digest.Mac(
    '就不告诉你就不告诉你就不告诉你',
    '互撸娃互撸娃一根藤上七朵菊花')

bucket = 'foobar'

import qiniu.rs
import qiniu.io

client = qiniu.rs.Client(mac=mac)
print client.batch_delete([])
print client.stat('img1temp', 'world-cup.gif')  # 这里会hang很久然后挂掉

from python-sdk.

hbrls avatar hbrls commented on July 17, 2024

+1 hang很久然后挂掉

from python-sdk.

philiptzou avatar philiptzou commented on July 17, 2024

@shuaishuai 试试#117

from python-sdk.

hbrls avatar hbrls commented on July 17, 2024

升级到6.1.7之后还是会偶尔出现同样的问题,也遇到过新错误

socket.error: [Errno 104] Connection reset by peer
socket.error: [Errno 110] Connection timed out

总之就是http出错太正常了,不可能指望七牛100%可用,但是ret, err到底值不值得信赖?官方给个说法吧,用try...except...也挺好的,但是两个都用就太丑了。

@philiptzou 服务器上不敢乱升级,拖了好久,见谅。

from python-sdk.

longbai avatar longbai commented on July 17, 2024

@shuaishuai 之前badstatus line 是因为 有错误码超过1000,会出现异常,现在已经调整了。如果碰到其他错误,能否帮忙给下调用栈,我再修改下。

from python-sdk.

hbrls avatar hbrls commented on July 17, 2024

刚发生的

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
    *args, **kwargs
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 405, in execute
    results['<local-only>'] = task.run(*args, **new_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
    return self.wrapped(*args, **kwargs)
  File "/home/admin/bitbucket/42smart.com/fabfile/logs.py", line 25, in upload
    if qiniu_upload(key, file_path):
  File "/home/admin/bitbucket/42smart.com/fabfile/__init__.py", line 48, in qiniu_upload
    ret, err = qiniu.io.put_file(uptoken, key, file_path)
  File "/usr/local/lib/python2.7/dist-packages/qiniu/io.py", line 71, in put_file
    return put(uptoken, key, f, extra)
  File "/usr/local/lib/python2.7/dist-packages/qiniu/io.py", line 55, in put
    ret, err, code = rpc.Client(conf.UP_HOST).call_with_multipart("/", fields, files)
  File "/usr/local/lib/python2.7/dist-packages/qiniu/rpc.py", line 73, in call_with_multipart
    return self.call_with(path, mr, content_type, mr.length())
  File "/usr/local/lib/python2.7/dist-packages/qiniu/rpc.py", line 47, in call_with
    resp = self.round_tripper("POST", path, body, header)
  File "/usr/local/lib/python2.7/dist-packages/qiniu/rpc.py", line 25, in round_tripper
    resp = self._conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line 1034, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 371, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import qiniu
>>> qiniu.__version__
'6.1.7'
>>>

from python-sdk.

philiptzou avatar philiptzou commented on July 17, 2024

@longbai

和我们周一Q群上报的似乎是同一个错?

from python-sdk.

longbai avatar longbai commented on July 17, 2024

看起来像是访问超时,数据没有读到,status line也没有读取到,我稍后会加上个异常捕获。

from python-sdk.

longbai avatar longbai commented on July 17, 2024

fixed by #125

from python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.