import asyncio
from threading import Thread
import time print('main start:',time.time()) async def start(i):
print(i, time.time())
await asyncio.sleep(i)
b=run(i)
if b is not None:
await asyncio.wait(b)
else:
print('all complete',time.time())
return True def run(content):
if content<3:
tasks=[]
tasks.append(start(content+1))
tasks.append(start(content+1))
tasks.append(start(content+1))
return tasks
print('end running', time.time()) def start_loop(loop):
asyncio.set_event_loop(loop)
loop.run_forever() new_loop=asyncio.new_event_loop()
t=Thread(target=start_loop,args=(new_loop,))
t.start() a=asyncio.run_coroutine_threadsafe(start(1),new_loop) while a._state !='FINISHED':
time.sleep(1)
print(a._state) print(new_loop.is_closed(),'checking')
new_loop.stop()
new_loop._csock.send(b'\0')
print(new_loop.is_closed(),'checking')

  

foreve结束的更多相关文章

  1. bootstrap-datetimepicker 进一步跟进~~~开始时间和结束时间的样式显示

    上次简单介绍了一下:05.LoT.UI 前后台通用框架分解系列之——漂亮的时间选择器(http://www.cnblogs.com/dunitian/p/5524019.html) 这次深入再介绍一下 ...

  2. Android Studio的SVN Performing VCS Refresh/Commit 长时间不结束

    给Android Studio项目里面的一个文件改名以后,再提交SVN时总是提示冲突,没办法解决.再后来不知道怎么弄的,每次提交时停留在SVN Performing VCS Refresh始终都不会完 ...

  3. acm结束了

    最后一场比赛打完了.之前为了记录一些题目,开了这个博客,现在结束了acm,这个博客之后也不再更新了. 大家继续加油!

  4. 关于break语句如何结束多重循环的嵌套

    在Java中的break语句功能大体上同c语言, 用于循环语句中,表示结束当前循环. 但是有时候在循环嵌套语句中,仅仅靠一 个break语句想实现是不够的. 例: 如果想使sum在501时就直接输出, ...

  5. Easyui 设置datagrid 进入编辑状态,保存结束编辑

    在datagrid中如何实现让一行进入编辑状态,修改数据后,保存信息呢? //点击列表变成文本框,进入可编辑状态 $(function () { var doc = $(document), tabl ...

  6. SpringMVC中如何在网站启动、结束时执行代码(详细,确保可用)

        在一个网站启动.结束时,我们经常有些操作是需要执行的. 熟悉Asp.net的朋友,使用Global.asax很容易就搞定,在其中有Application_Start和Application_E ...

  7. EXT5 时间框控制(开始时间不能大于结束时间)

    1.网上看的大部分代码都是利用vtype : 'dateRange'  EXT的这个属性,但是可能由于环境问题还是怎么样,我就是实现不了想要的效果. 然后研究了一下,在时间框的listeners 监听 ...

  8. 关于PHP中<?php ?>的结束标签是否添加

    在纯PHP代码中“?>”结束标签最好不要添加 原因:容易导致输出多余的空白或者换行,以及由此产生的一些报错. 比如a.php文件中,在?>标签后面多出空格或者换行,而当b.php文件引入a ...

  9. S1293和S2220KTV项目结束

    1.界面原型(前台的界面搭建一下) 2.数据库 3.架构设计 4.约定的文件抽取 2015年7月20日下午 歌星点歌三界面的联动,数据动态加载 01.点击第一个LIstView,弹出第二个ListVi ...

随机推荐

  1. PageHelper分页插件

    在mybatis配置文件(SqlMapConfig.xml)中配置 <?xml version="1.0" encoding="UTF-8" ?> ...

  2. DL中epoch、batch等的意义【转载】

    转自:深度学习中 number of training epochs 中的 epoch到底指什么? - 知乎 https://www.zhihu.com/question/43673341 1. (1 ...

  3. [Java] Header checkBox in Jtable

    The reference is from here. 在Jtable里面我们可能会有checkbox, 而有时候我们有很多checkbox需要同时check或者同时uncheck的时候, 如果有一个 ...

  4. cocos2d-x JS 纯代码渲染Lable描边

    /** * Enables shadow style and sets color, offset and blur radius styles. * @param {cc.Color} shadow ...

  5. Java包装

    public class Test2 { public static void main(String[] args) { /*String str = "..............&qu ...

  6. 强化学习--Actor-Critic---tensorflow实现

    完整代码:https://github.com/zle1992/Reinforcement_Learning_Game Policy Gradient  可以直接预测出动作,也可以预测连续动作,但是无 ...

  7. django 网站的搭建(2)

    这里使用nginx+uwsgi的方法来搭建生产环境 1,pip3.5  install uwsgi 下载uwsgi ,这里就不做测试了,一般不会出错 2,将django与uwsgi连接在一起 毕竟ru ...

  8. STL之List容器

    1.List容器 1) list是一个双向链表容器,可高效地进行插入删除元素. 2)list不可以随机存取元素,所以不支持at.(pos)函数与[]操作符.It++(ok) it+5(err) 3)头 ...

  9. WebAppInitializer类,代替web.xml

    package com.ssm.yjblogs.config; import javax.servlet.MultipartConfigElement; import javax.servlet.Se ...

  10. 入坑tensorflow

    win10 CPU版,anaconda prompt命令行一句话,pip install --upgrade tensorflow搞定.比caffe好装一万倍. gpu版没装成,首先这个笔记本没装cu ...