当前位置: 首页 > news >正文

Python asyncio.gather returns a future aggregating results from the given coroutines/futures.

Return a future aggregating results from the given coroutines/futures.
Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in.
All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily
the order of results arrival). If return_exceptions is True,exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first
raised exception will be immediately propagated to the returned future.

 

 

import uuid
from datetime import datetime
import time
import threading
import psutil
import os
import asyncioidx=0
idx_lock=threading.Lock()def get_idx():global idxwith idx_lock:idx+=1current_idx=idxreturn current_idxdef get_time_uuid():return f'{get_idx()}_{datetime.now().strftime('%Y%m%d%H%M%S%f')}_{uuid.uuid4().hex}'def get_uuid_time():return f'{get_idx()}_{uuid.uuid4().hex}_{datetime.now().strftime('%Y%m%d%H%M%S%f')}'async def print_time_uuid():print(get_time_uuid())async def print_uuid_time():print(get_uuid_time())async def asyncio_gather_func():while True:await asyncio.gather(         print_uuid_time(),print_time_uuid()                )await asyncio.sleep(1)if __name__=='__main__':try:asyncio.run(asyncio_gather_func())except Exception as ex:print(f"{datetime.now()},{str(ex)}")

 

 

 

 

image

 

 

 

image

 

http://www.jsqmd.com/news/403361/

相关文章:

  • [firewall]
  • 大量小额携程任我行礼品卡高效回收渠道解析 - 京顺回收
  • AI原生应用领域自然语言理解的未来展望
  • MacOS 操作系统的 Sketch 设计软件入门
  • 大模型数学基础3
  • 语义检索中的增量索引:实时更新策略与技术实现
  • Gemini生成摇滚音乐音频
  • 智能垃圾分类系统|基于java+ vue智能垃圾分类系统(源码+数据库+文档)
  • 大数据环境下RabbitMQ的消息压缩技术
  • BISHI70 【模板】组合数
  • 费雪的竞争优势分析:持续成功的关键
  • Flink与Hive集成:批流一体的大数据仓库方案
  • AI 与提示工程在环保场景的应用探索,提示工程架构师视角
  • 基于Simulink的悬架模型与主动悬架控制策略研究
  • C++ 多线程与并发系统取向(五)—— std::atomic:原子操作与状态一致性(类比 Java Atomic)
  • 2026.2.22
  • Python threading.Thread(target=lambda:[])
  • AI在法律尽职调查中的应用与架构实现
  • 实测50款东南亚语言配音工具,重点推荐以下性价比高的7款
  • 医疗器械手机APP开发工程师职位深度解析与面试指南
  • 深度解析:消费电子领域安卓开发工程师的核心能力与实践路径
  • 深度解析:苏州虹保世纪科技 Android 开发工程师职位要求与面试准备
  • 提示工程架构师必知:安全标准的评估方法
  • 芒格的“极端后果“思维在气候适应性技术投资中的应用
  • Python implement repeatable functions via while True loop and time.sleep
  • Python repeatable timer to implement recycled printing via schedule
  • 使用embedding进行分词 - f
  • 【开题答辩全过程】以 哈尔滨市小酒窝APP为例,包含答辩的问题和答案
  • 基于小信号建模的下垂控制稳定分析,文章完全浮现。 关键词:微电网,下垂控制,小信号模型,根轨迹...
  • flex与bison学习之字符统计程序