首页 > 编程语言 > 详细

Python3.5 试用

时间:2015-06-03 06:18:48      阅读:345      评论:0      收藏:0      [点我收藏+]

集成开发环境:WingIDE5.1.4 暂不支持,

import tornado
#loop =tornado.ioloop.IOLoop.instance() #导入错误。

from tornado.ioloop import IOLoop #正确的方式
loop = IOLoop.instance()


aysnc和await的用法:

import time

async def long_time_proc(num):
    #asyncio.sleep(2)
    time.sleep(3)
    return  hex(num)

async def display_res(num):
    r = await long_time_proc(num) #await 
    print("r:"+r, time.time())

loop = asyncio.get_event_loop()
# Blocking call which returns when the display_date() coroutine is done
loop.run_until_complete(display_res(6))
loop.run_until_complete(display_res(5))
loop.close()

与tornado的loop

import tornado
loop =tornado.ioloop.IOLoop.instance() 

from tornado.ioloop import IOLoop
loop = IOLoop.instance() 
def finished():
    print ("ff")
loop.add_future( display_res(6), finished )
loop.add_future( display_res(5), finished )       
loop.start()

暂时通不过,参见:https://mail.python.org/pipermail/python-dev/2015-May/139851.html

Python3.5 试用

原文:http://my.oschina.net/cppblog/blog/424112

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!