当前位置:首页>python>Python并发编程实战

Python并发编程实战

  • 2026-07-01 04:35:53
Python并发编程实战

🔥 Python并发编程实战:多线程、多进程、协程,到底该用哪个?一文彻底讲透!

导语:面试被问"多线程和多进程的区别"答不上来?写爬虫用了多线程却感觉没快多少?异步协程听着高大上却不知道怎么用?别慌!本文用最通俗的语言+最实用的代码,带你彻底搞懂Python并发编程的三大武器。读完这篇,你不仅能回答面试官的刁钻问题,还能在实际项目中选对方案,让程序飞起来!


🤔 先搞清楚:为什么需要并发?

假设你要下载100张图片,每张需要2秒。串行执行需要200秒,但如果同时下载10张,可能只需要20秒。这就是并发的威力。

但Python的并发方式不止一种,选错了反而更慢。先看一张对比表:

方式
适用场景
能利用多核
程序复杂度
多线程
I/O密集型(网络请求、文件读写)
❌ 受GIL限制
⭐⭐
多进程
CPU密集型(计算、数据处理)
⭐⭐⭐
异步协程
高并发I/O(爬虫、Web服务)
⭐⭐⭐⭐

关键结论:I/O等待多 → 用线程或协程;计算量大 → 用多进程。


🧵 一、多线程:I/O密集型任务的首选

什么是GIL?一句话解释

Python(CPython)有个"全局解释器锁"(GIL),简单说就是同一时刻只能有一个线程执行Python字节码。所以多线程不能利用多核CPU进行并行计算。

但!是!当线程在等待I/O(网络、文件、数据库)时,GIL会释放,其他线程就能干活了。这就是为什么多线程适合I/O密集型任务

实战:多线程下载网页

import threading
import time
import requests

# 待下载的URL列表
urls = [
"https://httpbin.org/delay/1",
"https://httpbin.org/delay/1",
"https://httpbin.org/delay/1",
"https://httpbin.org/delay/1",
"https://httpbin.org/delay/1",
]

defdownload(url, index):
"""下载单个网页"""
    print(f"🧵 线程{index}开始下载: {url}")
    resp = requests.get(url, timeout=10)
    print(f"✅ 线程{index}下载完成,状态码: {resp.status_code}")

# ========== 串行执行 ==========
start = time.time()
for i, url in enumerate(urls):
    download(url, i)
print(f"\n⏱ 串行耗时: {time.time() - start:.2f}秒")

# ========== 多线程执行 ==========
start = time.time()
threads = []
for i, url in enumerate(urls):
    t = threading.Thread(target=download, args=(url, i))
    threads.append(t)
    t.start()  # 启动线程

for t in threads:
    t.join()   # 等待所有线程完成
print(f"⏱ 多线程耗时: {time.time() - start:.2f}秒")

输出对比

⏱ 串行耗时: 5.23秒
⏱ 多线程耗时: 1.15秒   ← 快了4.5倍!

用线程池更优雅

手动管理线程太麻烦?用concurrent.futures的线程池:

from concurrent.futures import ThreadPoolExecutor, as_completed
import requests

defdownload(url):
    resp = requests.get(url, timeout=10)
returnf"{url} -> {resp.status_code}"

urls = ["https://httpbin.org/delay/1"] * 10

# 创建线程池,最多5个线程同时工作
with ThreadPoolExecutor(max_workers=5as pool:
# 提交所有任务
    futures = [pool.submit(download, url) for url in urls]

# 按完成顺序获取结果
for future in as_completed(futures):
        result = future.result()
        print(f"✅ {result}")

print("全部下载完成!")

💡 小贴士as_completed按任务完成顺序返回结果,不是提交顺序。如果需要保持顺序,用pool.map()代替。


🏭 二、多进程:榨干CPU的每一滴性能

什么时候用多进程?

当你的任务是纯计算(比如图像处理、数据加密、大规模数学运算),多线程因为GIL的存在几乎没用。这时候必须上多进程——每个进程有独立的Python解释器和GIL,真正实现并行。

实战:多进程加速计算

from multiprocessing import Pool
import time

defheavy_computation(n):
"""模拟CPU密集型任务:计算大量累加"""
    total = 0
for i in range(n * 1000000):
        total += i
return total

numbers = [100200300400]

# ========== 串行执行 ==========
start = time.time()
results = [heavy_computation(n) for n in numbers]
print(f"⏱ 串行耗时: {time.time() - start:.2f}秒")

# ========== 多进程执行 ==========
start = time.time()
with Pool(processes=4as pool:
    results = pool.map(heavy_computation, numbers)
print(f"⏱ 多进程耗时: {time.time() - start:.2f}秒")

在4核CPU上,多进程版本通常能快3-4倍

进程间通信:用Queue传数据

进程之间内存是隔离的,不能像线程那样共享变量。用Queue传递数据:

from multiprocessing import Process, Queue

defproducer(queue):
"""生产者:往队列里放数据"""
for i in range(5):
        queue.put(f"数据包-{i}")
        print(f"📦 生产: 数据包-{i}")
    queue.put(None)  # 发送结束信号

defconsumer(queue):
"""消费者:从队列里取数据"""
whileTrue:
        item = queue.get()
if item isNone:
break
        print(f"📬 消费: {item}")

if __name__ == "__main__":
    q = Queue()
    p1 = Process(target=producer, args=(q,))
    p2 = Process(target=consumer, args=(q,))

    p1.start()
    p2.start()
    p1.join()
    p2.join()

⚡ 三、异步协程:高并发场景的终极武器

协程是什么?一个比喻就懂

想象你在餐厅点餐:

  • 多线程:雇5个服务员,每人服务一桌(开销大)
  • 协程:1个超级服务员,A桌等菜时去服务B桌,B桌等菜时去服务C桌(高效!)

协程的核心是在I/O等待时切换到其他任务,用一个线程就能处理成千上万的并发连接。

实战:异步批量请求

import asyncio
import aiohttp
import time

asyncdefdownload(session, url, index):
"""异步下载单个网页"""
    print(f"⚡ 任务{index}开始: {url}")
asyncwith session.get(url) as resp:
        data = await resp.text()
        print(f"✅ 任务{index}完成,长度: {len(data)}")
return data

asyncdefmain():
    urls = ["https://httpbin.org/delay/1"] * 10

# 限制并发数为5,避免一次性请求太多
    semaphore = asyncio.Semaphore(5)

asyncdeflimited_download(session, url, index):
asyncwith semaphore:
returnawait download(session, url, index)

asyncwith aiohttp.ClientSession() as session:
        tasks = [
            limited_download(session, url, i)
for i, url in enumerate(urls)
        ]
        results = await asyncio.gather(*tasks)

    print(f"\n🎉 全部完成!共获取 {len(results)} 个结果")

# 运行异步主函数
start = time.time()
asyncio.run(main())
print(f"⏱ 异步耗时: {time.time() - start:.2f}秒")

10个请求,限制5并发,总耗时约2秒——如果是串行需要10秒!

async/await语法详解

import asyncio

asyncdefmake_coffee():
    print("☕ 开始磨咖啡豆...")
await asyncio.sleep(2)  # 模拟等待(I/O操作)
    print("☕ 咖啡好了!")
return"美式咖啡"

asyncdefmake_toast():
    print("🍞 开始烤面包...")
await asyncio.sleep(1)  # 模拟等待
    print("🍞 面包好了!")
return"全麦吐司"

asyncdefbreakfast():
"""同时做咖啡和面包"""
# 用gather同时运行多个协程
    coffee, toast = await asyncio.gather(
        make_coffee(),
        make_toast()
    )
    print(f"🎉 早餐就绪:{coffee} + {toast}")

asyncio.run(breakfast())
# 总耗时2秒,而不是3秒!

🎯 四、实战场景速查表

场景1:批量爬取网页

# 推荐:异步协程(aiohttp)
import asyncio
import aiohttp

asyncdeffetch_all(urls):
asyncwith aiohttp.ClientSession() as session:
        tasks = [session.get(url) for url in urls]
        responses = await asyncio.gather(*tasks, return_exceptions=True)
return [await r.text() ifnot isinstance(r, Exception) else str(r) 
for r in responses]

场景2:批量处理文件

# 推荐:多线程(文件I/O是阻塞的)
from concurrent.futures import ThreadPoolExecutor

defprocess_file(filepath):
with open(filepath, 'r'as f:
        data = f.read()
# 处理数据...
returnf"已处理: {filepath}"

files = ["file1.txt""file2.txt""file3.txt"]
with ThreadPoolExecutor(max_workers=4as pool:
    results = list(pool.map(process_file, files))

场景3:批量图片处理

# 推荐:多进程(CPU密集型)
from multiprocessing import Pool
from PIL import Image

defresize_image(path):
    img = Image.open(path)
    img.thumbnail((800800))
    img.save(f"resized_{path}")
return path

images = ["img1.jpg""img2.jpg""img3.jpg"]
with Pool() as pool:
    pool.map(resize_image, images)

⚠️ 五、避坑指南

坑1:多线程中的共享变量

# ❌ 错误示范:多线程修改共享变量
counter = 0

defincrement():
global counter
for _ in range(100000):
        counter += 1# 不是原子操作!结果可能不对

# ✅ 正确做法:加锁
import threading
lock = threading.Lock()

defsafe_increment():
global counter
for _ in range(100000):
with lock:
            counter += 1

坑2:协程里不要用阻塞操作

# ❌ 错误:在协程里用time.sleep会阻塞整个事件循环
asyncdefbad_example():
    time.sleep(5)  # 阻塞!其他协程全卡住

# ✅ 正确:用asyncio.sleep
asyncdefgood_example():
await asyncio.sleep(5)  # 非阻塞,其他协程可以运行

坑3:多进程记得用if __name__ == "__main__"

# Windows上必须加这个,否则会无限递归创建进程!
if __name__ == "__main__":
with Pool(4as p:
        p.map(worker, data)

📊 总结:一张图选对并发方案

你的任务是什么?
    │
    ├── 需要等待I/O(网络、文件、数据库)
    │       │
    │       ├── 并发量 < 100 → 多线程(简单好用)
    │       └── 并发量 > 100 → 异步协程(性能更强)
    │
    └── 需要大量计算(图片处理、数据分析、加密)
            │
            └── 多进程(充分利用多核CPU)

记住这个口诀

  • 🧵 I/O等待用线程
  • 🏭 计算密集用进程
  • ⚡ 高并发用协程

💬 互动时间

你在实际项目中用过哪种并发方案?遇到过什么坑?欢迎在评论区分享你的经验!

如果觉得这篇文章有帮助,点赞+在看+转发三连走起,让更多Python开发者看到!👇


#Python并发编程 #多线程 #多进程 #异步协程 #asyncio #Python性能优化 #GIL #Python实战

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 18:09:30 HTTP/2.0 GET : https://f.mffb.com.cn/a/489891.html
  2. 运行时间 : 0.191610s [ 吞吐率:5.22req/s ] 内存消耗:4,949.95kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=cbaa1d51a9e08e71eb57b6e9f9b80d07
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000842s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001262s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.002454s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001350s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001044s ]
  6. SELECT * FROM `set` [ RunTime:0.002061s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001390s ]
  8. SELECT * FROM `article` WHERE `id` = 489891 LIMIT 1 [ RunTime:0.005924s ]
  9. UPDATE `article` SET `lasttime` = 1783159771 WHERE `id` = 489891 [ RunTime:0.017493s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.009875s ]
  11. SELECT * FROM `article` WHERE `id` < 489891 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001483s ]
  12. SELECT * FROM `article` WHERE `id` > 489891 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001988s ]
  13. SELECT * FROM `article` WHERE `id` < 489891 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001981s ]
  14. SELECT * FROM `article` WHERE `id` < 489891 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003487s ]
  15. SELECT * FROM `article` WHERE `id` < 489891 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.008867s ]
0.196364s