zed Blog

Thinking will not overcome fear but action will.

炒股笔记心得

基本原则 找准固定熟悉的几只股票(美的,顺丰等), 一年找准一两次想对低点(提前心里设定预期),2/3 仓买入,等待时机卖出, 赚15个点卖2/3 留1/3; 忍, 切记要耐住性子,要慢慢等待时机,实际不到,宁可不赚钱,也不要着急下手!!!;

python logging

多进程安全的handler

Python 多进程下保证时间轮转日志安全 1.Python logging 模块是线程安全的吗? 答案是,日志handler 的处理流程, handle →  emit → stream.wrtite → stream.flush Handle 基类的 handle方法 这一步骤已经上了锁, 也就是每条日志都是安全的刷入到文件中,才会有下一条,因此不会造成日志混乱。另外日志切分也是再em...

python logging

python 多后缀文件的logging handler

直接看代码 class MulitSuffixFileDistributeHandler(Handler): """ support file_suffix in extra param passed into logger._log func distribute logs to diffrence file by file_suffix in extra para...

python gc

python 内存泄漏gc卡顿问题分析

一、python 内存泄漏的2个可能原因 循环引用,且循环引用的对象重写了__del__ 方法,导致python gc 发现后,无法回收导致内存增长,这种垃圾我们称为uncollectable 对象(可以回收的循环引用对象称为 unreachable); 缓存或者全局容器,出现了大量正常对象,导致内存持续增长; 二、python 内存 回收机制简述 内存回收,主要是以引...

python2 OrderDict 循环引用导致频繁gc

python2 的OrderDict 导致的内存回收问题 线上定位到周期性的卡顿,最终定位到 2代GC 导致的卡顿,通过gc 模块排查,顺带发现python2 的 OrderDict 会产生循环引用对象 产生原因 OrderedDict 有序性采用双向链表存储,正常情况下 需要有__del__ 方法处理双向链表, 早期的python2 版本是这样做的,但是后期发现对于相互引用...

python new style class mro

python mro prescription

python 方法解析顺序【MRO】 By zc 当写 python 多重继承时,会碰到方法的继承覆盖问题,因此需要研究 python 关于方法的解析顺序问题,也就是MRO 问题 MRO 算法 定义 MRO 需要满足 local precedence order(局部有限顺序)、monotocity(单调性)这两个顺序 在一个复杂的多继承体系中,给定类C,很难确定...

k8s and docker install

centos6.3 k8s 集群搭建

centos 6.3, kernel 3.10 install docker and k8s install docker download builded docker-ce from url unpack download file, use tar xf file sudo cp docker/* /usr/bin create config used by dock...

Python thread safe singleton decorator

线程安全的 Python 单例装饰器

你真的能写好一个单例模式吗?简单的单例模式,大家都会写,装饰器版本的写法、重写__new__版本的写法,但是如何确保线程安全呢? 下面就简单看一下线程安全的装饰器吧。 talk is cheap, show me the code! def singleton(cls): lock = threading.Lock() @functools.wraps(cls) ...

My First Post

Hello World, Hello Blog

Hey 这是我的第一篇博客。 欢迎访问 https://www.zcwxt.com 进入你的博客主页,新的文章将会出现在你的主页上.