上一页 1 2 3 4 5 6 ··· 16 下一页

2021年1月3日

上下文管理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) 编辑

2021年1月2日

让对象支持上下文管理

摘要: 让我们的对象支持上下文管理(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 思此狂 阅读(293) 评论(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) 编辑

2020年12月19日

threading Event

摘要: 通过threading.Event()可以创建一个事件管理标志,该标志(event)默认为False,event对象主要有四种方法可以调用: event.wait(timeout=None):调用该方法的线程会被阻塞,如果设置了timeout参数,超时后,线程会停止阻塞继续执行; event.set 阅读全文

posted @ 2020-12-19 22:48 思此狂 阅读(594) 评论(0) 推荐(0) 编辑

2020年11月27日

python中的eval 和 exec 和 execfile

摘要: #eval 函数用来计算python表达式并返回结果#exec 可以执行动态的python代码,不返回结果 def hello(): print("hello world") eval("hello()") 输出 hello world exec("hello()") 输出 hello world# 阅读全文

posted @ 2020-11-27 22:12 思此狂 阅读(317) 评论(0) 推荐(0) 编辑

2020年11月21日

cloud-init 常见问题

摘要: 1 日志文件都放在了哪里 1 /var/log/cloud-init.log2 服务的输出 systemd 启动的系统可以查看 journalctl 日志 sysvinit/upstart 启动的系统应该在 /var/log/cloud-init-output.log 里,这块我需要确认下 如何收集 阅读全文

posted @ 2020-11-21 20:20 思此狂 阅读(2744) 评论(0) 推荐(0) 编辑

2020年11月20日

systemd

摘要: systemd-cgls 指令,根据 cgroup 将运行的进程分组来同时实现两者。 要显示您系统中的全部 cgroup 层级systemd-cgls 查看 memory 资源管控器的 cgroup 树systemd-cgls memorysystemd-cgls cpusystemd-cgls d 阅读全文

posted @ 2020-11-20 20:15 思此狂 阅读(244) 评论(0) 推荐(1) 编辑

2020年11月15日

cloud-init 的命令行

摘要: 各服务对应的 cloud-init 执行的命令行 cloud-init-local.service : cloud-init init --local cloud-init.service: cloud-init init cloud-config.service: cloud-init modul 阅读全文

posted @ 2020-11-15 21:48 思此狂 阅读(771) 评论(0) 推荐(0) 编辑

cloud-init 基本介绍

摘要: cloud-init 主要是为了初始化实例信息,用户在购买实例时配置的实例密码,Hostname,user-data等,及实例启动时系统配置,如 repo源,ssh认证密钥等。 cloud-init 在启动时分5个阶段执行,对应于系统中服务分别是 1 Generator 2 Local 对应系统服务 阅读全文

posted @ 2020-11-15 21:30 思此狂 阅读(4614) 评论(0) 推荐(1) 编辑

上一页 1 2 3 4 5 6 ··· 16 下一页

导航

< 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
点击右上角即可分享
微信分享提示