Django视图函数执行,不在主线程中,直接 loop = asyncio.new_event_loop() # 更不能loop = asyncio.get_event_loop() 会触发 RuntimeError: There is no current event loop in thread 因为asyncio程序中的每个线程都有自己的事件循环,但它只会在主线程中为你自动创建一个事件循环.所以如果你asyncio.get_event_loop在主线程中调用一次,它将自动创建一个循环对象并
先写一个静态类: /// <summary> /// 公用基础函数库 /// <remarks>作者: YangYxd</remarks> /// </summary> public static class Common { /// <summary> /// 返回一个以毫秒为单位的时间 (0001-01-01 00:00:00.000 算起) /// </summary> public static long Ticks { ge
简单了解 在py3中内置了asyncio模块.其编程模型就是一个消息循环. 模块查看: from .base_events import * from .coroutines import * #协程模块,可以将函数装饰为协程 from .events import * #事件模块,事件循环和任务调度都将使用到他 from .futures import * #异步并发模块,该模块对task封装了许多方法,代表将来执行或没有执行的任务的结果.它和task上没有本质上的区别 from .locks