当前位置:首页>python>Python asyncio模块详细介绍

Python asyncio模块详细介绍

  • 2026-02-05 00:47:02
Python asyncio模块详细介绍

1. 创始时间与作者

  • 创始时间asyncio 模块首次出现在 Python 3.4 版本中,于 2014年3月 发布,在 Python 3.5 中引入 async/await 语法

  • 核心开发者

    • Guido van Rossum:Python 创始人,asyncio 的主要设计者

    • Yury Selivanov:async/await 语法的主要贡献者,Python 核心开发者

    • Python 核心团队:持续改进异步编程生态系统

  • 项目定位:Python 标准异步 I/O 框架,提供协程-based 的并发编程模型

2. 官方资源

  • Python 官方文档https://docs.python.org/3/library/asyncio.html

  • 源码地址https://github.com/python/cpython/tree/main/Lib/asyncio

  • PEP 3156https://www.python.org/dev/peps/pep-3156/

  • 教程指南https://docs.python.org/3/library/asyncio-dev.html

3. 核心功能

4. 应用场景

1. 基础异步编程
import asyncioimport timeasyncdef say_after(delaymessage):"""异步函数示例"""await asyncio.sleep(delay)print(message)return f"{message} 完成"async def basic_async_demo():"""基础异步演示"""print(f"开始时间: {time.strftime('%X')}")# 顺序执行result1 = await say_after(2"Hello")result2 = await say_after(1"World")print(f"顺序执行结果: {result1}, {result2}")print(f"结束时间: {time.strftime('%X')}")# 并发执行print("\n--- 并发执行 ---")print(f"开始时间: {time.strftime('%X')}")task1 = asyncio.create_task(say_after(2"Hello"))task2 = asyncio.create_task(say_after(1"World"))results = await asyncio.gather(task1task2)print(f"并发执行结果: {results}")print(f"结束时间: {time.strftime('%X')}")# 运行示例asyncio.run(basic_async_demo())
2. 异步网络编程
import asyncioimport aiohttpimport timeclass AsyncWebClient:"""异步Web客户端"""def __init__(self):self.session = Noneasync def fetch_url(selfurlsession):"""获取URL内容"""try:async with session.get(urltimeout=10as response:content = await response.read()return {'url'url,'status'response.status,'size'len(content),'success'True                }except Exception as e:return {'url'url,'status'0,'size'0,'success'False,'error'str(e)            }async def download_multiple_urls(selfurls):"""并发下载多个URL"""async with aiohttp.ClientSession() as session:tasks = []for url in urls:task = asyncio.create_task(self.fetch_url(urlsession))tasks.append(task)results = await asyncio.gather(*tasks)return resultsasync def controlled_concurrency(selfurlsmax_concurrent=3):"""控制并发度的下载"""semaphore = asyncio.Semaphore(max_concurrent)async def bounded_fetch(url):async with semaphore:return await self.fetch_url(urlself.session)async with aiohttp.ClientSession()  as session:self.session = sessiontasks = [bounded_fetch(url)  for url in urls]results = await asyncio.gather(*tasks)return resultsasync def network_demo():"""网络编程演示"""client = AsyncWebClient()urls = ['https://httpbin.org/delay/1','https://httpbin.org/delay/2','https://httpbin.org/delay/1','https://httpbin.org/json','https://httpbin.org/html'    ]print("开始并发下载...")start_time = time.time()# 方法1: 完全并发results1 = await client.download_multiple_urls(urls)# 方法2: 控制并发度results2 = await client.controlled_concurrency(urlsmax_concurrent=2)end_time = time.time()print(f"\n下载完成,耗时: {end_time - start_time:.2f}秒")successful_downloads = sum(for in results1 if r['success'])print(f"成功下载: {successful_downloads}/{len(urls)}")for result in results1:status = "成功" if result['success'else "失败"print(f"URL: {result['url']} - {status} - 大小: {result['size']}")# 运行示例asyncio.run(network_demo())
3. 异步Web服务器
import asynciofrom aiohttp import webimport jsonimport timeclass AsyncWebServer:"""异步Web服务器"""def __init__(self):self.app = web.Application()self.setup_routes()self.request_count = 0def setup_routes(self):"""设置路由"""self.app.router.add_get('/'self.handle_root)self.app.router.add_get('/status'self.handle_status)self.app.router.add_get('/api/data'self.handle_api_data)self.app.router.add_post('/api/echo'self.handle_api_echo)async def handle_root(selfrequest):"""处理根路径请求"""return web.Response(text="欢迎使用异步Web服务器!",content_type='text/html'        )async def handle_status(selfrequest):"""处理状态查询"""self.request_count += 1status_info = {'server''Async Web Server','timestamp'time.time(),'request_count'self.request_count,'active_tasks'len(asyncio.all_tasks())        }return web.json_response(status_info)async def handle_api_data(selfrequest):"""处理API数据请求"""# 模拟数据库查询await asyncio.sleep(0.1)data = {'items': [                {'id'1'name''Item 1''value'100},                {'id'2'name''Item 2''value'200},                {'id'3'name''Item 3''value'300}            ],'total'3,'timestamp'time.time()        }return web.json_response(data)async def handle_api_echo(selfrequest):"""处理回显请求"""try:data = await request.json()response_data = {'echo'data,'received_at'time.time(),'method'request.method            }return web.json_response(response_data)except Exception as e:return web.json_response(                {'error'str(e)}, status=400            )async def start_server(selfhost='localhost'port=8080):"""启动服务器"""runner = web.AppRunner(self.app)await runner.setup()site = web.TCPSite(runnerhostport)await site.start()print(f"服务器启动在 http://{host}:{port}")print("可用端点:")print("  GET  /          - 欢迎页面")print("  GET  /status    - 服务器状态")print("  GET  /api/data  - 获取数据")print("  POST /api/echo  - 回显数据")return runnerasync def webserver_demo():"""Web服务器演示"""server = AsyncWebServer()runner = await server.start_server()try:# 保持服务器运行await asyncio.Future()  # 永远等待except KeyboardInterrupt:print("\n正在关闭服务器...")finally:await runner.cleanup()# 运行服务器(取消注释以运行)# asyncio.run(webserver_demo())
4. 高级异步模式
import asyncioimport randomimport timefrom dataclasses import dataclassfrom typing import ListOptional@dataclassclass TaskResult:"""任务结果"""task_idintstatusstrresultOptional[str] = NoneerrorOptional[str] = Noneexecution_timefloat = 0.0class AdvancedAsyncPatterns:"""高级异步模式"""def __init__(selfmax_concurrent_tasks=5):self.max_concurrent_tasks = max_concurrent_tasksself.completed_tasks = 0self.failed_tasks = 0async def simulated_task(selftask_idintdurationfloat->str:"""模拟异步任务"""# 10% 的概率失败if random.random() <0.1:raise Exception(f"任务 {task_id} 随机失败")# 模拟工作await asyncio.sleep(duration)return f"任务 {task_id} 完成,耗时 {duration:.2f}秒"async def run_with_timeout(selftask_idinttimeoutfloat = 3.0->TaskResult:"""带超时的任务执行"""start_time = time.time()try:duration = random.uniform(1.04.0)result = await asyncio.wait_for(self.simulated_task(task_idduration), timeout=timeout            )execution_time = time.time() -start_timereturn TaskResult(task_id=task_id,status='success',result=result,execution_time=execution_time            )except asyncio.TimeoutError:execution_time = time.time() -start_timereturn TaskResult(task_id=task_id,status='timeout',error=f"任务超时 ({timeout}秒)",execution_time=execution_time            )except Exception as e:execution_time = time.time() -start_timereturn TaskResult(task_id=task_id,status='failed',error=str(e),execution_time=execution_time            )async def producer_consumer_pattern(selfnum_tasksint):"""生产者-消费者模式"""queue = asyncio.Queue(maxsize=10)results = []async def producer():"""生产者协程"""for in range(num_tasks):await queue.put(i)print(f"生产者: 添加任务 {i} 到队列")await asyncio.sleep(0.1)  # 控制生产速度# 发送结束信号for in range(self.max_concurrent_tasks):await queue.put(None)async def consumer(consumer_idint):"""消费者协程"""while True:task_id = await queue.get()if task_id is None:queue.task_done()breakprint(f"消费者 {consumer_id}: 处理任务 {task_id}")result = await self.run_with_timeout(task_id)results.append(result)queue.task_done()await asyncio.sleep(0.05)  # 模拟处理时间# 启动生产者和消费者producer_task = asyncio.create_task(producer())consumer_tasks = [asyncio.create_task(consumer(i))for in range(self.max_concurrent_tasks)        ]# 等待所有任务完成await producer_taskawait queue.join()# 取消消费者for task in consumer_tasks:task.cancel()await asyncio.gather(*consumer_tasksreturn_exceptions=True)return resultsasync def task_with_retry(selftask_idintmax_retriesint = 3->TaskResult:"""带重试机制的任务"""for attempt in range(max_retries):result = await self.run_with_timeout(task_id)if result.status == 'success':return resultprint(f"任务 {task_id} 第 {attempt + 1} 次尝试失败: {result.error}")await asyncio.sleep(1)  # 重试前等待return TaskResult(task_id=task_id,status='failed',error=f"经过 {max_retries} 次重试后仍然失败"        )async def run_demo(self):"""运行演示"""print("=== 生产者-消费者模式 ===")start_time = time.time()results = await self.producer_consumer_pattern(20)end_time = time.time()# 分析结果success_count = sum(for in results if r.status == 'success')timeout_count = sum(for in results if r.status == 'timeout')failed_count = sum(for in results if r.status == 'failed')print(f"\n任务执行统计:")print(f"总任务数: {len(results)}")print(f"成功: {success_count}")print(f"超时: {timeout_count}")print(f"失败: {failed_count}")print(f"总耗时: {end_time - start_time:.2f}秒")# 带重试的任务print("\n=== 带重试机制的任务 ===")retry_results = await asyncio.gather(*[self.task_with_retry(ifor in range(5)]        )for result in retry_results:status_icon = "✅" if result.status == 'success' else "❌"print(f"{status_icon} 任务 {result.task_id}: {result.status}")async def advanced_patterns_demo():"""高级模式演示"""patterns = AdvancedAsyncPatterns(max_concurrent_tasks=3)await patterns.run_demo()# 运行示例asyncio.run(advanced_patterns_demo())

5. 底层逻辑与技术原理

核心架构
关键技术
  1. 事件循环 (Event Loop)

    • 协程调度和IO事件处理的核心

    • 使用选择器(selector)监听文件描述符

    • 管理定时器和回调

  2. 协程 (Coroutine)

    async def example():# 挂起点result = await some_async_operation()return result
  3. Future 和 Task

    • Future:异步操作的最终结果容器

    • Task:包装协程的Future子类,用于调度执行

  4. async/await 语法

    • async def:定义异步函数

    • await:挂起协程,等待异步操作完成

  5. IO多路复用

    • 在Unix系统使用epoll/kqueue

    • 在Windows系统使用IOCP

    • 统一抽象为selector

事件循环工作流程
# 简化的事件循环伪代码class EventLoop:def run_until_complete(selffuture):while not future.done():# 1. 执行就绪的回调self._run_ready_callbacks()# 2. 轮询IO事件events = self._selector.select(timeout)# 3. 处理IO事件for fdevent in events:self._handle_io_event(fdevent)# 4. 执行定时器self._run_timers()# 5. 调度协程self._schedule_coroutines()

6. 安装与配置

基础安装
# asyncio 是 Python 标准库的一部分,无需额外安装# 验证安装python -c"import asyncio; print(asyncio.__doc__)"
环境要求
组件最低要求推荐配置
Python3.4+3.7+
操作系统Windows 7+/Linux 2.6+/macOS 10.9+同左
内存512MB4GB+
可选依赖安装
# 常用异步库pip install aiohttp     # 异步HTTP客户端/服务器pip install aiomysql    # 异步MySQL客户端pip install aiopg       # 异步PostgreSQL客户端pip install aioredis    # 异步Redis客户端pip install websockets  # 异步WebSocket
平台特定优化
import asyncioimport platformdef optimize_event_loop():"""优化事件循环配置"""system = platform.system()if system == 'Windows':# Windows 使用 ProactorEventLooploop = asyncio.ProactorEventLoop()asyncio.set_event_loop(loop)print("使用 ProactorEventLoop (Windows)")elif system == 'Linux':# Linux 使用 epolltry:import uvloopasyncio.set_event_loop_policy(uvloop.EventLoopPolicy())print("使用 uvloop (Linux)")except ImportError:loop = asyncio.SelectorEventLoop()asyncio.set_event_loop(loop)print("使用 SelectorEventLoop (Linux)")else:# macOS 和其他系统loop = asyncio.SelectorEventLoop()asyncio.set_event_loop(loop)print("使用 SelectorEventLoop (macOS/其他)")# 应用优化optimize_event_loop()

7. 性能指标

操作类型执行时间内存开销并发能力
协程创建0.1-1μs1-2KB数万协程
上下文切换0.01-0.1μs可忽略极高
网络IO0.1-10ms可忽略数千连接
文件IO1-100ms可忽略受限于系统

8. 高级功能使用

1. 自定义事件循环策略
import asyncioimport timefrom typing import ListDictclass MonitoringEventLoopPolicy(asyncio.DefaultEventLoopPolicy):"""监控事件循环策略"""def __init__(self):super().__init__()self.loop_creation_time = {}self.task_stats = {}def new_event_loop(self):"""创建新的事件循环"""loop = super().new_event_loop()loop_id = id(loop)self.loop_creation_time[loop_id] = time.time()self.task_stats[loop_id] = {'tasks_created'0,'tasks_completed'0,'exceptions_caught'0        }# 添加监控self._add_monitoring_to_loop(looploop_id)return loopdef _add_monitoring_to_loop(selflooploop_id):"""向事件循环添加监控"""original_create_task = loop.create_taskdef monitored_create_task(coroname=None):task = original_create_task(coroname=name)self.task_stats[loop_id]['tasks_created'] += 1# 添加完成回调def task_done_callback(future):self.task_stats[loop_id]['tasks_completed'] += 1if future.exception():self.task_stats[loop_id]['exceptions_caught'] += 1task.add_done_callback(task_done_callback)return taskloop.create_task = monitored_create_taskdef get_stats(self->Dict:"""获取统计信息"""return {'total_loops'len(self.loop_creation_time),'task_stats'self.task_stats,'loop_uptime': {loop_idtime.time() -create_timefor loop_idcreate_time in self.loop_creation_time.items()            }        }async def demo_monitoring():"""监控演示"""# 设置自定义事件循环策略policy = MonitoringEventLoopPolicy()asyncio.set_event_loop_policy(policy)async def sample_task(task_id):await asyncio.sleep(1)if task_id%5 == 0:raise Exception(f"任务 {task_id} 故意失败")return f"任务 {task_id} 完成"# 创建多个任务tasks = [sample_task(i)  for in range(10)]results = await asyncio.gather(*tasksreturn_exceptions=True)# 显示统计信息stats = policy.get_stats()print("事件循环统计:")print(f"总事件循环数: {stats['total_loops']}")for loop_idloop_stats in stats['task_stats'].items():print(f"\n事件循环 {loop_id}:")print(f"  创建的任务数: {loop_stats['tasks_created']}")print(f"  完成的任务数: {loop_stats['tasks_completed']}")print(f"  捕获的异常数: {loop_stats['exceptions_caught']}")print(f"  运行时间: {stats['loop_uptime'][loop_id]:.2f}秒")# 运行示例asyncio.run(demo_monitoring())
2. 异步上下文管理器
import asyncioimport aiohttpfrom contextlib import asynccontextmanagerfrom typing import AsyncIteratorclass AsyncDatabaseConnection:"""模拟异步数据库连接"""def __init__(selfconnection_string):self.connection_string = connection_stringself.is_connected = Falseasync def connect(self):"""连接数据库"""print(f"连接到: {self.connection_string}")await asyncio.sleep(0.5)  # 模拟连接时间self.is_connected = Trueprint("连接成功")async def disconnect(self):"""断开连接"""if self.is_connected:print("断开数据库连接")self.is_connected = Falseawait asyncio.sleep(0.1)async def execute_query(selfquery):"""执行查询"""if not self.is_connected:raise RuntimeError("数据库未连接")print(f"执行查询: {query}")await asyncio.sleep(0.2)  # 模拟查询时间return f"查询结果: {query}"@asynccontextmanagerasync def database_connection(connection_stringstr->AsyncIterator[AsyncDatabaseConnection]:"""异步上下文管理器"""db = AsyncDatabaseConnection(connection_string)try:await db.connect()yield dbfinally:await db.disconnect()class AsyncResourcePool:"""异步资源池"""def __init__(selfpool_size=5):self.pool_size = pool_sizeself._pool = asyncio.Queue()self._in_use = set()async def __aenter__(self):"""异步上下文管理器入口"""for in range(self.pool_size):await self._pool.put(f"资源-{i}")return selfasync def __aexit__(selfexc_typeexc_valexc_tb):"""异步上下文管理器出口"""# 清理资源while not self._pool.empty():await self._pool.get()async def acquire(self->str:"""获取资源"""resource = await self._pool.get()self._in_use.add(resource)return resourceasync def release(selfresourcestr):"""释放资源"""if resource in self._in_use:self._in_use.remove(resource)await self._pool.put(resource)async def context_manager_demo():"""上下文管理器演示"""# 使用异步上下文管理器print("=== 数据库连接演示 ===")async with database_connection("postgresql://localhost/mydb"asdb:result1 = await db.execute_query("SELECT * FROM users")result2 = await db.execute_query("SELECT COUNT(*) FROM orders")print(result1)print(result2)# 使用资源池print("\n=== 资源池演示 ===")async with AsyncResourcePool(3aspool:# 并发获取资源tasks = []for in range(5):task = asyncio.create_task(use_resource(pooli))tasks.append(task)await asyncio.gather(*tasks)async def use_resource(poolAsyncResourcePooluser_idint):"""使用资源"""resource = await pool.acquire()try:print(f"用户 {user_id} 获取资源: {resource}")await asyncio.sleep(1)  # 模拟资源使用print(f"用户 {user_id} 使用资源完成: {resource}")finally:await pool.release(resource)# 运行示例asyncio.run(context_manager_demo())

9. 与同类工具对比

特性asynciothreadingmultiprocessingconcurrent.futures
并发模型协程/事件循环线程进程线程/进程池
内存开销极低中等中等
性能极高(I/O)中等高(CPU)中等
编程复杂度中等中等
适用场景I/O密集型I/O密集型CPU密集型通用并发
GIL影响受限制线程池受限制

10. 企业级应用案例

  1. 高性能Web服务

    • FastAPI、Sanic等异步Web框架

    • 微服务架构和API网关

  2. 实时数据处理

    • 消息队列消费者

    • 实时流处理系统

  3. 网络爬虫

    • 高并发网页抓取

    • 分布式爬虫系统

  4. 游戏服务器

    • 实时多人游戏后端

    • 游戏状态同步

  5. 金融服务

    • 高频交易系统

    • 实时市场数据推送


总结

asyncio 是 Python 异步编程的现代标准,核心价值在于:

  1. 高性能:单线程处理数万并发连接

  2. 低开销:协程比线程内存开销小几个数量级

  3. 现代语法:async/await 语法直观易用

  4. 生态丰富:庞大的异步库生态系统

技术亮点

  • 基于事件循环的协程调度

  • 完整的异步IO支持

  • 丰富的同步原语和工具

  • 跨平台高性能实现

适用场景

  • 高并发网络应用

  • I/O密集型服务

  • 实时数据处理

  • 微服务和云原生应用

安装使用

# 无需安装,直接导入python -c"import asyncio; print('asyncio 模块可用')"

学习资源

  • 官方文档:https://docs.python.org/3/library/asyncio.html

  • 异步编程指南:https://docs.python.org/3/library/asyncio-dev.html

  • 实战教程:https://realpython.com/async-io-python/

asyncio 代表了 Python 并发编程的未来方向,特别适合构建高性能、高并发的网络应用和服务,是现代 Python 开发者必须掌握的核心技术之一。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 12:16:08 HTTP/2.0 GET : https://f.mffb.com.cn/a/471085.html
  2. 运行时间 : 0.252646s [ 吞吐率:3.96req/s ] 内存消耗:4,710.75kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=b460452788a41ed34d21f23a0a6d381d
  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.000943s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001659s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.003696s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.011258s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.002038s ]
  6. SELECT * FROM `set` [ RunTime:0.001763s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.002175s ]
  8. SELECT * FROM `article` WHERE `id` = 471085 LIMIT 1 [ RunTime:0.043134s ]
  9. UPDATE `article` SET `lasttime` = 1770437768 WHERE `id` = 471085 [ RunTime:0.045590s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.004058s ]
  11. SELECT * FROM `article` WHERE `id` < 471085 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.006803s ]
  12. SELECT * FROM `article` WHERE `id` > 471085 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000636s ]
  13. SELECT * FROM `article` WHERE `id` < 471085 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.003866s ]
  14. SELECT * FROM `article` WHERE `id` < 471085 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.038011s ]
  15. SELECT * FROM `article` WHERE `id` < 471085 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.010264s ]
0.254319s