01 2021 档案

关于网络中断
摘要:阿里云ECS 配置网卡多队列 提升中断处理性能 https://help.aliyun.com/document_detail/52559.html?spm=a2c4g.11174283.6.990.b2e552fekaIQx9 关于亲和性设置 https://www.cnblogs.com/bam 阅读全文

posted @ 2021-01-17 21:49 思此狂 阅读(175) 评论(0) 推荐(0) 编辑

python对象判断isintance/is等
摘要:isintance/type 的区别尽量使用isintance 内置的 type() 函数可以用来查询变量所指的对象类型。isinstance(1, int) 区别: class A: pass class B(A): pass isinstance(A(), A) # returns True t 阅读全文

posted @ 2021-01-04 23:30 思此狂 阅读(237) 评论(0) 推荐(0) 编辑

上下文管理contextlib
摘要:contextmanager from contextlib import contextmanager class Query(object): def __init__(self, name): self.name = name def query(self): print('Query inf 阅读全文

posted @ 2021-01-03 22:55 思此狂 阅读(75) 评论(0) 推荐(0) 编辑

让对象支持上下文管理
摘要:让我们的对象支持上下文管理(with语句) 为了让一个对象兼容 with 语句,你需要实现 __enter__() 和 __exit__() 方法 demo: class WithTest: def __enter__(self): print("enter") return self #这里需要r 阅读全文

posted @ 2021-01-02 21:16 思此狂 阅读(79) 评论(0) 推荐(0) 编辑

线程锁lock&rlock
摘要:首先关于锁: 1 使用锁会影响性能 2 锁可能谁导致死锁 比如: 线程A acquire a 等待b 线程B acquire b 等待a 这种资源竞争就会导致死锁 【Lock】 lock 不能连续获取两次(死锁了), 因为第二个锁会一直等待第一个释放 【Rlock】 可重入锁 Rlock 在同一个线 阅读全文

posted @ 2021-01-02 20:56 思此狂 阅读(292) 评论(0) 推荐(0) 编辑

threading.local
摘要:import threading import time def music(a,b): fo = open("test.txt1", "w") fo.write(a+b) fo.close() def move(c,d): fo = open("test.txt2", "w") fo.write( 阅读全文

posted @ 2021-01-02 20:37 思此狂 阅读(91) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5
点击右上角即可分享
微信分享提示