
python
文章平均质量分 52
哒哒儿
这个作者很懒,什么都没留下…
展开
-
flask框架,api压力测试
threaded=True,threading.Tread(target=function_name,args=(list),name='thread_name')原创 2017-10-07 21:11:55 · 2935 阅读 · 0 评论 -
dev warning python
一、服务调用1. 判断是否需要重试(retring);2. 设置超时时间;3. 对状态码进行判断;4. 对于异常!200的处理,具体业务具体分析,不论是向上抛出还是内部消费,异常日志收集都是必要的5. 后期日志的分析。处理异常,判断是上游的问题还是入参问题...二、新开发服务1. 超时时间 压测(并发跑批)得出 报告2. 是否有负载,有的话 nginx:connect ...原创 2019-03-18 23:02:38 · 205 阅读 · 0 评论 -
pymongo beson binary 存储
痛点:由于在python中使用numpy 进行数据操作的时候需要转换成mongo的数据类型,才能进行存储,在使用的时候再取出 转换成numpy的数据类型 作为模型的入参。这样中间多做了一层转换,而且numpy类型有24种,很难每个都判断做转换。解决方案:为了不影响模型的入参,我们使用pickle存储成二进制 ,使用的时候进行转换。以二进制的方式存储。# -*- coding: utf...原创 2019-01-30 14:14:07 · 547 阅读 · 0 评论 -
python 中 list 是否是线程安全的?
是不是不共享数据就不会发生线程不安全?线程安全就是多线程访问时,采取了加锁的机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问知道该线程读取完,其他的线程才可使用,不会出现数据不一致或数据污染的问题线程不安全就是不提供数据访问保护,有可能出现多个线程现后更改数据造成所得到的数据是脏数据。总的来说,只要线程之间没有共享资源,那么就是线程安全的,有共享资源,为了保证线...原创 2019-03-18 23:16:28 · 7445 阅读 · 0 评论 -
Py
python 动态声明变量 并赋值 dict、set 或 list 的 in 运算符效率原创 2019-04-08 18:50:24 · 180 阅读 · 0 评论 -
python 2 vs python3
python 2 python3 ValueError: cannot convert float NaN to integer python2 vs python3 AttributeError: 'unicode' object has...原创 2019-04-09 19:05:47 · 295 阅读 · 0 评论 -
scrapyd 问题 builtins.AttributeError: 'int' object has no attribute 'splitlines'
错误提示web.Server Traceback (most recent call last):builtins.AttributeError:'int' object has no attribute 'splitlines'回退版本Scrapy==1.6.0 Twisted==18.9.0原创 2019-04-21 12:43:39 · 6231 阅读 · 6 评论 -
OSError: mysql_config not found || Exception: Wrong MySQL configuration:
pip install mysqlclientOSError: mysql_config not foundFile "<string>", line 1, in <module> File "/private/var/folders/qw/y81w55mx5d3gx8rlzy09yvfh0000gn/T/pip-install-h2htc37w/mysqlc...原创 2019-07-01 11:47:38 · 629 阅读 · 0 评论 -
pip 镜像源
lishulongdeMacBook-Pro:~ lishulong$ cat ~/.pip/pip.conf [global]index-url = https://pypi.tuna.tsinghua.edu.cn/simple#[global]extra-index-url = http://pypi.douban.com/simple #豆瓣源,可以换成其他的源trusted...原创 2019-03-18 23:01:46 · 230 阅读 · 0 评论 -
gevent debug in pycharm
error:Exception ignored in: '_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval' 解决方式:原创 2019-01-09 10:41:18 · 1315 阅读 · 0 评论 -
python程序乱码解决
python乱码解决原创 2016-05-30 16:15:40 · 894 阅读 · 0 评论 -
anaconda
anaconda multi env原创 2017-12-09 22:37:59 · 3718 阅读 · 2 评论 -
python 垃圾回收 GC
一. 小整数对象池(常驻内存)整数在程序中使用广泛,Python为了优化速度,使用了小整数对象池,避免为整数频繁申请和销毁内存空间。Python对小整数的定义是[-5,257) 左闭右开 这些整数对象是提前建立好的,不会被回收,在一个Python程序中,所有位于这个范围内的整数使用的都是同一个对象。同理,单个字母也是这样的,但是当定义2个相同的字符串时,引用计数为0,触发垃圾回收。原创 2018-01-10 12:21:28 · 1463 阅读 · 0 评论 -
tornado
如何理解tornado作为webserver,采用的是asynchronous IO的网络模型,很高效的模型简单的python框架,url基于正则,有自己的模板实现没有orm 类似于web.py非阻塞异步io,类似于nodejsweb framework,可以直接构建自己的web程序支持WSGI(python web server gateway interface)可以和其他一些...原创 2018-03-12 15:53:42 · 443 阅读 · 1 评论 -
在jupyter notebook中安装第三方包(卸载、查看)
在jupyter中安装卸载查看第三方包import pipdef pip_install(package): pip.main(['install', package])def pip_list(): pip.main(['list'])def pip_uninstall(package): pip.main(['uninstall', package])...原创 2018-04-15 11:56:44 · 18375 阅读 · 1 评论 -
搭建jupyter服务器
ubuntu@py-model01br-p002:~$ conda -Vconda 4.3.30ubuntu@py-model01br-p002:~$ lsanaconda3 Anaconda3-5.0.1-Linux-x86_64.sh nohup.outubuntu@py-model01br-p002:~$ cd /opensource/ubuntu@py-model01br-p...原创 2018-04-15 12:02:56 · 847 阅读 · 0 评论 -
pymongo 如何处理异常 AutoReconnect ,防止数据丢失
Retrying Tutorial在使用pymongo的时候 ,自带的线程池 存在 连接失效raise AutoReconnect("connection closed")解决方式,加入retry 防止丢失数据from pymongo.errors import AutoReconnectdef retry_if_auto_reconnect_error(exc...原创 2018-06-11 12:44:03 · 6275 阅读 · 0 评论 -
Python 操作 AWS S3
详情https://boto3.readthedocs.io/en/latest/reference/services/s3.htmpip install boto3 == 1.6.12#### pip install boto3==1.6.12-- coding: utf-8 --“”” @contact: lishulong.never@gmail.com ...原创 2018-07-05 11:32:26 · 4841 阅读 · 0 评论 -
xgboost 缺少依赖导致的安装不成功,试试这个
ERROR: Complete output from command python setup.py egg_info: ERROR: rm -f -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost clang-omp++ -std=c++0x -W...原创 2019-07-01 11:57:00 · 2155 阅读 · 0 评论