当前位置:首页>python>Python 并发与 asyncio 13.1 管理子进程

Python 并发与 asyncio 13.1 管理子进程

  • 2026-01-31 19:15:36
Python 并发与 asyncio 13.1 管理子进程

13 管理子进程

本章内容包括:

  • 异步运行多个子进程
  • 处理子进程的标准输出
  • 使用标准输入与子进程通信
  • 避免子进程中的死锁和其他陷阱

很多应用一辈子都用不着离开 Python 的世界。我们从其他 Python 库和模块中调用代码,或者使用 multiprocessing、multithreading 来并发执行代码。但并不是所有想交互的东西都写成 Python。比如你可能有个用 C++、Go、Rust 或其他语言写的现成应用,它们性能更好,或干脆就是现成的,不用再重写一遍。你也可能想用系统自带的命令行工具,像 GREP 用来搜大文件、cURL 做 HTTP 请求,或者其他一大堆随手可用的应用。

在标准 Python 里,我们可以用 subprocess 模块来启动不同程序作为独立进程。跟大多数其他模块一样,标准的 subprocess API 是阻塞式的,这使得它和 asyncio 不兼容,除非配合多线程或多进程。好在 asyncio 提供了一个模仿 subprocess 模块的模块,让我们可以用协程异步地创建和管理子进程。

这一章,我们就来学习如何用 asyncio 创建和管理子进程的基础知识——以一个用别种语言写的程序为例。还会教你怎么处理输入输出,读取标准输出,以及把数据从你的主程序发给子进程。

13.1 创建子进程

假设你想扩展一个已有的 Python Web API 功能。你们公司另一个团队已经用命令行工具做了一个批量处理功能,但问题是这个工具是用 Rust 写的。既然这东西已经存在了,自然不想再去用 Python 重新造轮子。那有没有办法,在现有的 Python API 里直接用上它的功能呢?

好在这玩意儿有命令行接口,我们就可以通过子进程来复用它。我们把它当命令行程序调起来,运行在一个独立的子进程中。然后读取它的返回结果,该拿来就拿,再也不用自己重写了。

那问题来了:怎么创建一个子进程并运行它?asyncio 本身就提供了两个协程函数来创建子进程:asyncio.create_subprocess_shell 与 asyncio.create_subprocess_exec。这两个函数都会返回一个 Process 实例,它有几个方法可以用来等待进程结束、终止进程等。既然两样都差不多,为什么要两个?什么时候该用哪个?

create_subprocess_shell 会在系统安装的 shell(比如 zshbash)里运行子进程。通常来说,除非必须用 shell 特性,否则你应该首选 create_subprocess_exec。因为用 shell 会埋坑:不同机器可能装的 shell 不同,或者同一个 shell 配置也不一样。这样就很难保证程序在各种环境里行为一致。

我们先用最简单的例子试试,写个 asyncio 程序运行一个命令行程序。这次我们用 ls 命令来列出当前目录的内容,做个测试(虽然实际项目里不会这么干)。如果你用的是 Windows,就把 ls -l 换成 cmd /c dir

列表 13.1 在子进程中运行一个简单命令

import asynciofrom asyncio.subprocess import Processasync def main():    process: Process = await asyncio.create_subprocess_exec('ls''-l')    print(f'进程 PID 是: {process.pid}')    status_code = await process.wait()    print(f'状态码: {status_code}')asyncio.run(main())

上面这段代码里,我们用 create_subprocess_exec 启动了 ls -l 命令。你也可以在后面加更多参数。这里我们传了 -l,能显示更多文件信息,比如是谁创建的。创建完进程后,我们打印出进程号,然后调用 wait 协程。这个协程会一直等,直到子进程结束。一结束就返回状态码,正常应该是 0。

默认情况下,子进程的输出会直接发送到我们自己的标准输出。所以运行时你会看到类似这样的输出(根据你目录内容略有不同):

进程 PID 是: 54438total 8drwxr-xr-x   4 matthewfowler  staff  128 Dec 23 15:20 .drwxr-xr-x  25 matthewfowler  staff  800 Dec 23 14:52 ..-rw-r--r--   1 matthewfowler  staff    0 Dec 23 14:52 __init__.py-rw-r--r--   1 matthewfowler  staff  293 Dec 23 15:20 basics.py状态码: 0

注意,wait 协程会一直阻塞,直到子进程结束。但谁也不知道进程要跑多久,甚至有可能永远跑不完。如果担心“逃逸进程”,就得用 asyncio.wait_for 加个超时。不过有个坑:wait_for 超时后会终止它所在的协程任务,并不会杀死子进程本身,只停止那个等待的任务。

所以我们得换个更靠谱的方式关掉超时的进程。幸运的是,Process 有两个方法能派上用场:terminate 与 killterminate 发送 SIGTERM 信号,kill 发送 SIGKILL 信号。这两个方法都不是协程,也是非阻塞的——它们只是发信号。如果你还想知道终止后的状态码,或者要等清理工作完成,还是得再次调用 wait

我们来试一下用 sleep 命令(在 Windows 上换成 cmd /c timeout 3)搞个长时间运行的子进程,然后强制终止它:

列表 13.2 终止一个子进程

import asynciofrom asyncio.subprocess import Processasync def main():    process: Process = await asyncio.create_subprocess_exec('sleep''3')    print(f'进程 PID 是: {process.pid}')    try:        status_code = await asyncio.wait_for(process.wait(), timeout=1.0)        print(status_code)    except asyncio.TimeoutError:        print('等待超时,正在终止...')        process.terminate()        status_code = await process.wait()        print(status_code)asyncio.run(main())

在这个例子中,我们创建了个要睡 3 秒的子进程,外层套了 wait_for,超时时间 1 秒。1 秒后 wait_for 会抛出 TimeoutError,在 except 块里我们手动终止进程,再等它结束并打印状态码。输出大概如下:

进程 PID 是: 54709等待超时,正在终止...-15

一点小提醒:except 块里的 wait 也有可能等很久,如果担心这个问题,可以也用 wait_for 包一层。

13.1.1 控制标准输出

前面的例子中,子进程的标准输出直接输出到了我们应用的控制台。但如果不想这样呢?也许你想对输出做点处理,又或者输出根本无关紧要,完全可忽略。

create_subprocess_exec 协程有个 stdout 参数,允许你指定输出去哪儿。这个参数接收一个枚举值,你可以选择:重定向到自己程序的标准输出、用 StreamReader 接收、或者直接丢进 /dev/null 忽略掉。

假设我们要同时运行多个子进程,并且显示它们各自的输出。为了区分是哪个进程的输出,我们可以给每个输出加个前缀,说明来源命令。下面我们用 ls -la 来试试。

列表 13.3 使用标准输出流读取器

import asynciofrom asyncio import StreamReaderfrom asyncio.subprocess import Processasync def write_output(prefix: str, stdout: StreamReader):    while line := await stdout.readline():        print(f'[{prefix}]: {line.rstrip().decode()}')async def main():    program = ['ls''-la']    process: Process = await asyncio.create_subprocess_exec(*program,                                                            stdout=asyncio                                                            .subprocess.PIPE)    print(f'进程 PID 是: {process.pid}')    stdout_task = asyncio.create_task(write_output(' '.join(program), process.stdout))    return_code, _ = await asyncio.gather(process.wait(), stdout_task)    print(f'进程返回: {return_code}')asyncio.run(main())

这里我们先定义了一个 write_output 协程,逐行读取输出流,并在每行前面加上前缀。在主协程里,我们创建了子进程,并设置 stdout 为 PIPE,让它把输出发给 StreamReader。然后我们启了一个任务来运行 write_output,并与 process.wait() 并发运行。当你运行这个程序,会发现输出都带上了命令前缀:

进程 PID 是: 56925[ls -la]: total 32[ls -la]: drwxr-xr-x   7 matthewfowler  staff  224 Dec 23 09:07 .[ls -la]: drwxr-xr-x  25 matthewfowler  staff  800 Dec 23 14:52 ..[ls -la]: -rw-r--r--   1 matthewfowler  staff    0 Dec 23 14:52 __init__.py进程返回: 0

然而用管道传输数据时,死锁风险特别高。尤其是当子进程产生大量输出而你没及时读取时,很容易卡住。来演示一下:

列表 13.4 生成大量输出

import sys[sys.stdout.buffer.write(b'Hello there!!\n'for _ in range(1000000)]sys.stdout.flush()

这段代码连续向标准输出缓冲区写 100 万次 Hello there!!,然后一次性刷新。我们看看用管道接住这个程序但不读取会发生什么。

列表 13.5 管道死锁问题

import asynciofrom asyncio.subprocess import Processasync def main():    program = ['python3''listing_13_4.py']    process: Process = await asyncio.create_subprocess_exec(*program,                                                            stdout=asyncio                                                            .subprocess.PIPE)    print(f'进程 PID 是: {process.pid}')    return_code = await process.wait()    print(f'进程返回: {return_code}')asyncio.run(main())

如果你运行这个例子,会看到刚打出进程号,就再也没动静了,程序永久卡住,只能强行关闭。如果没遇到,就增大循环次数,肯定会出现问题。

这么简单个程序为啥会死锁?关键在于 StreamReader 缓冲区的行为。当缓冲区满了,往里写数据就会阻塞,直到缓冲区有空位。可这时子进程还在拼命写输出,于是它就依赖 StreamReader 释放空间。但你压根没去读,缓冲区永远不空,死锁就此形成。

之前我们是靠一边等 wait 一边读输出避免了这种问题——只要缓冲区填满,我们就能实时读走,不让子进程卡住。所以用管道时,务必及时消费数据,别让缓冲区被堵住

当然还有更绝的解法:别用 wait,改用 communicate 这个协程。它在子进程结束后才返回,而且会自动持续读取标准输出和错误输出,避免死锁。来改成用 communicate 修复刚才的问题:

列表 13.6 使用 communicate

import asynciofrom asyncio.subprocess import Processasync def main():    program = ['python3''listing_13_4.py']    process: Process = await asyncio.create_subprocess_exec(*program,                                                            stdout=asyncio                                                            .subprocess.PIPE)    print(f'进程 PID 是: {process.pid}')    stdout, stderr = await process.communicate()    print(stdout)    print(stderr)    print(f'进程返回: {process.returncode}')asyncio.run(main())

这次运行你会发现所有输出瞬间刷出来,然后是 None —— 因为你没往标准输出写任何东西。内部 communicate 会创建几个后台任务不停地读取标准输出和标准错误,彻底避免死锁。但这也有个致命缺点:你无法在输出过程中即时响应。如果需要实时处理输出,比如看到某个关键字就终止,或触发新任务,那就得老老实实用 wait,但一定要记得及时读取输出,不然照样卡住。

还有一个问题是:communicate 会把所有标准输出和标准输入的数据全部缓存在内存里。如果子进程输出巨量数据,很可能撑爆内存。下节我们会讲怎么解决这些问题。

13.1.2 并发运行多个子进程

现在咱们掌握了创建、终止、读取输出的基本操作,下面开始实战:并发运行多个程序

想象一下,你要加密内存中的多段文本,出于安全考虑,决定用 Twofish 加密算法。可是 hashlib 没支持这个算法,只好另想办法。我们可以用 gpg(GNU Privacy Guard,PGP 的免费替代品)命令行工具。官网下载地址:https://gnupg.org/download/(https://gnupg.org/download/)

首先定义好加密命令。用 gpg 可以设密码,选算法,然后把待加密的文本“喂”进去。例如要加密 "encrypt this!",命令是:

echo 'encrypt this!' | gpg -c --batch --passphrase 3ncryptm3 --cipher-algo TWOFISH

运行后会输出一堆乱码,类似:

?Q+??/??*??C??H`??`)R??u??7þ_{f{R;n?FE .?b5??(?i??????o\k?b<????`%

命令行上没问题,但你在用 create_subprocess_exec 时就废了,因为没法用 | 管道(create_subprocess_shell 才支持)。那怎么传入要加密的文本?别急,communicate 与 wait 不仅能传标准输出和错误,还能传标准输入。

communicate 协程在启动时还能指定输入数据。只要你把标准输入设成 PIPE,这些数据就会被传给子进程。太棒了!我们可以直接传字符串过去。

现在试试用随机文本加密 100 条,全都并发执行:

列表 13.7 并发加密文本

import asyncioimport randomimport stringimport timefrom asyncio.subprocess import Processasync def encrypt(text: str) -> bytes:    program = ['gpg''-c''--batch''--passphrase''3ncryptm3',        '--cipher-algo''TWOFISH']    process: Process = await asyncio.create_subprocess_exec(*program,                                                            stdout=asyncio                                                            .subprocess.PIPE,                                                            stdin=asyncio                                                            .subprocess.PIPE)    stdout, stderr = await process.communicate(text.encode())    return stdoutasync def main():    text_list = [''.join(random.choice(string.ascii_letters) for _ in range(1000)) for _ in range(100)]    s = time.time()    tasks = [asyncio.create_task(encrypt(text)) for text in text_list]    encrypted_text = await asyncio.gather(*tasks)    e = time.time()    print(f'总耗时: {e - s}')    print(encrypted_text)asyncio.run(main())

这里的 encrypt 协程创建了 gpg 进程,并用 communicate 把待加密的文本传进去。为简化,我们只返回标准输出结果,也没处理异常——实际项目里肯定得加点容错逻辑。主函数里我们生成 100 个随机 1000 字符长的文本,对每个创建一个 encrypt 任务,并用 gather 并发运行。最后打印总时间和加密结果。

对比一下:把 await 加在 asyncio.create_task 前面,去掉 gather,那就是串行运行。你会发现并发版本明显快多了。

但你现在只加密了 100 个。要是变成几千甚至上万个呢?现在的代码是一口气创建 100 个进程,这在资源有限的机器上几乎等于自杀。不仅内存吃光,上下文切换的开销也会爆炸。

更糟的是,gpg 本身依赖共享状态(比如加密种子文件),你一旦并发开太多,很可能看到类似下面的报错:

gpg: waiting for lock on `/Users/matthewfowler/.gnupg/random_seed'...

不光进程太多,而且还被锁住,全在那儿傻等。那怎么办?当然是限制并发数。这时就该登场“信号量”了。既然任务是计算密集型,我们限制最大并发数等于你机器的核数,就很合理了。

试试看:用限定了核数的信号量,来加密 1000 个文本,看看效果:

列表 13.8 使用信号量的子进程

import asyncioimport randomimport stringimport timeimport osfrom asyncio import Semaphorefrom asyncio.subprocess import Processasync def encrypt(sem: Semaphore, text: str) -> bytes:    program = ['gpg''-c''--batch''--passphrase''3ncryptm3''--cipher-algo''TWOFISH']    async with sem:        process: Process = await asyncio.create_subprocess_exec(*program,                                                                stdout=asyncio                                                                .subprocess.PIPE,                                                                stdin=asyncio                                                                .subprocess.PIPE)        stdout, stderr = await process.communicate(text.encode())        return stdoutasync def main():    text_list = [''.join(random.choice(string.ascii_letters) for _ in range(1000)) for _ in range(1000)]    semaphore = Semaphore(os.cpu_count())    s = time.time()    tasks = [asyncio.create_task(encrypt(semaphore, text)) for text in text_list]    encrypted_text = await asyncio.gather(*tasks)    e = time.time()    print(f'总耗时: {e - s}')asyncio.run(main())

相比无限并发的版本,现在不但性能提升了,内存占用也降下来。你可能会觉得这不就跟第 6 章的 ProcessPoolExecutor 一样吗?没错!其实内部 ProcessPoolExecutor 就用了信号量来控制最大并发数。

我们现在已经掌握了创建、终止、并发运行子进程的基础知识。下一节,我们来看看怎么和子进程进行更互动式的通信

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 15:19:34 HTTP/2.0 GET : https://f.mffb.com.cn/a/470432.html
  2. 运行时间 : 0.091778s [ 吞吐率:10.90req/s ] 内存消耗:4,710.29kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=eede179edbb29a05ffb5fd1718725a0b
  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.000642s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000829s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000351s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000251s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000495s ]
  6. SELECT * FROM `set` [ RunTime:0.000195s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000510s ]
  8. SELECT * FROM `article` WHERE `id` = 470432 LIMIT 1 [ RunTime:0.000618s ]
  9. UPDATE `article` SET `lasttime` = 1770448774 WHERE `id` = 470432 [ RunTime:0.013603s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000251s ]
  11. SELECT * FROM `article` WHERE `id` < 470432 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001306s ]
  12. SELECT * FROM `article` WHERE `id` > 470432 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000600s ]
  13. SELECT * FROM `article` WHERE `id` < 470432 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000852s ]
  14. SELECT * FROM `article` WHERE `id` < 470432 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000657s ]
  15. SELECT * FROM `article` WHERE `id` < 470432 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.006460s ]
0.093311s