Comments (17)
@shuaishuai 收到,我们来看下
from python-sdk.
不赞成用ret+err处理一切异常,把处理不了的错误raise出来给外界catch才是pythonic的做法啊
from python-sdk.
@philiptzou 如果我没理解错的话,ret, err是go的做法吧
from python-sdk.
@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.
出错太频繁了,受不了了,用try except
了
from python-sdk.
@shuaishuai 请问您说的出错太频繁是什么错误?
from python-sdk.
@longbai 应用场景是我需要把log文件传到七牛,一个文件一个文件的传,比如传好access.log.1,接着传access.log.2,类推。大约30%左右会传失败,就是上面这个BadStatusLine错误,随机遇到,没有特征。我是在for循环里面跑的,如果不用try except,那么脚本就会挂掉。
from python-sdk.
貌似我也遇到这个问题了……
from python-sdk.
搞出来了个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.
+1 hang很久然后挂掉
from python-sdk.
from python-sdk.
升级到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.
@shuaishuai 之前badstatus line 是因为 有错误码超过1000,会出现异常,现在已经调整了。如果碰到其他错误,能否帮忙给下调用栈,我再修改下。
from python-sdk.
刚发生的
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.
和我们周一Q群上报的似乎是同一个错?
from python-sdk.
看起来像是访问超时,数据没有读到,status line也没有读取到,我稍后会加上个异常捕获。
from python-sdk.
fixed by #125
from python-sdk.
Related Issues (20)
- 为什么http._get里面不用session? HOT 2
- 上传同名文件覆盖问题 HOT 2
- 请问sdk中调用上传可以设置路径前缀吗? HOT 1
- 这个地方手误了? HOT 1
- python3.9 调用报错,有考虑支持3.9吗
- 不支持Python3.6?
- utils-->_file_iter函数有BUG,读取input_stream后seek没有归0,导致后续需要使用input_stream的内容,读取不到数据。 HOT 1
- python 3.9 TypeError: __init__() got an unexpected keyword argument 'encoding'
- How to download unlimited items from qiniu? HOT 2
- Python SDK
- 执行pfop.execute(key, ops, 1)方法时,抛出异常:AttributeError: 'module' object has no attribute '_post_with_auth' HOT 1
- python 用demo上传图片后,图片被裁剪了,怎么上传原始宽高的图片?
- sdk支持分片上传的接口吗 HOT 1
- 文件分片上传v2缺少metadata参数
- 请问怎么在不确定域名的情况下,生成文件的外链 HOT 1
- 七牛HTTP扩展字段参考链接无法打开 HOT 2
- [FeatureRequest]麻烦支持配置代理,生产环境无法直接访问外网,需要走代理服务器
- Ubuntu下使用systemd出现qiniu_pythonsdk_hostscache权限问题 HOT 1
- 文档问题!!!!
- 升级v7.11.x后上传报错 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-sdk.