摘要: GIL的定义: 在CPython中,这个全局解释器锁,也称之为GIL,是一个互斥锁,防止多个线程。在同一时间执行python字节码,这个锁是非常重要的,因为CPython的内存管理是非线程安全的,很多其他的特性依赖于GIL锁,所以即使它影响了程序效率也无法将其直接去除。 GIL的锁问题: 加锁的时机 阅读全文
posted @ 2020-07-19 22:44 topass123 阅读(141) 评论(0) 推荐(0) 编辑
摘要: #1. 实例化Thread #2. 继承Thread类 import time from threading import Thread def sleep_task(sleep_time): print("sleep {} seconds start!".format(sleep_time)) t 阅读全文
posted @ 2020-07-19 16:26 topass123 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 安装软件: pip instal pymysq pip install peewee 创建数据模型orm from peewee import * db = MySQLDatabase("spider", host="127.0.0.1", port=3306, user="root", passw 阅读全文
posted @ 2020-07-19 15:57 topass123 阅读(177) 评论(0) 推荐(0) 编辑