2023 年十二月 一 二 三 四 五 六 日 « 二 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 分类目录
-
近期文章
近期评论
- Dillon 发表在《Mac OS代理工具Proxifier》
- RobertFluch 发表在《Bash Shell 快捷键》
- brew 不可用,重新安装 发表在《Mac下删除自己安装的Python》
- 子陵 发表在《Mac下删除自己安装的Python》
- Yucun 发表在《Mac下删除自己安装的Python》
文章归档
标签
7-zip 7zx active record CentALT cookie crontab dreamhost eclipse EPEL fast GarageBand google hyk-proxy LITTECMS mail mysql2 MySQLdb netgear nginx office PIL ports Proxifier pydev python readability requests sleep timeout torrent ubuntu unicorn urllib2 urlopen web.py yum zoc 下载 二笔 亿恩科技 吉他 睡眠 编码 路由 郑州景安
Category Archives: Python
dreamhost上运行python(web.py)
费了2个晚上的时间,终于搞定了,看看效果 http://dh-py.yanghao.org/ 分别用cgi和fastcgi测试了一下,看结果: cgi: [plain]/usr/sbin/ab -c 4 -n 300 http://dh-py.yanghao.org/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking dh-py.yanghao.org (be patient) Completed 100 requests … Continue reading
Posted in Python
2 Comments
urllib2.urlopen超时的问题
urlopen方法在Python 2.6之前是没有timeout参数的,只能通过全局的socket超时设置,2.6之后增加了timeoute参数。 我在Mac下使用自带的Python 2.6的urlopen,没有设置timeout参数,结果在网络环境不好的情况下,时常出现read()方法没有任何反应的问题,程序卡死在read()方法里,搞了大半天,才找到问题,给urlopen加上timeout就ok了,设置了timeout之后超时之后read超时的时候会抛出socket.timeout异常 不知道其它版本有没有这个问题,还只是2.6的问题 想要程序稳定还需要给urlopen加上异常处理,再加上出现异常重试,程序就完美了。 代码: [python] fails = 0 while True: try: if fails >= 3: break f = urllib2.urlopen(url,timeout=20) page = f.read().decode(‘gbk’) except: fails += 1 else: break [/python]
Mac下安装MySQLdb
本来以为使用easy_install安装MySQLdb很简单,结果还是费了一点劲才安装好。 问题及解决办法: easy_install MySQLdb提示 Couldn’t find index page for ‘MySQLdb’ (maybe misspelled?) No local packages or download links found for MySQLdb error: Could not find suitable distribution for Requirement.parse(‘MySQLdb’) 原来MySQLdb在pypi上面叫MySQL-python 解决办法:使用easy_install MySQL-python可以找到了,第2个问题也就出现了 easy_install MySQL-python提示 EnvironmentError: mysql_config not found 这个问题是因为找不到mysql_config的原因导致的,不知道安装时候用mysql_config做了什么,解决办法有2个,网上都是说改site.cfg里面的mysql_config路径,但我使用easy_install没办法改 解决办法:在PATH里增加/usr/local/mysql/bin解决 … Continue reading