- 博客(13)
- 资源 (5)
- 收藏
- 关注
翻译 asyncio 系列六、asyncio的网络原语
官网连接:https://docs.python.org/zh-cn/3.7/library/asyncio-stream.html流是用于处理网络连接的高级 async/await-ready 原语。流允许发送和接收数据,而不需要使用回调或低级协议和传输。下面官网例子,是一个使用 asyncio streams 编写的 TCP echo 客户端示例:import asyncio...
2019-05-24 22:42:05 1768
翻译 asyncio 系列五、asyncio的事件循环
官网连接:https://docs.python.org/zh-cn/3.7/library/asyncio-eventloop.html#asyncio.loop.run_in_executor事件循环是每个 asyncio 应用的核心。 事件循环会运行异步任务和回调,执行网络 IO 操作,以及运行子进程。里面封装的方法用于上层函数调用。本节所针对的主要是低层级代码、库和框架的编写者,...
2019-05-24 22:29:23 7738 1
翻译 python 协程库 asyncio 翻译列表
asyncio 模块官网连接:https://docs.python.org/zh-cn/3.7/library/asyncio.html同步原语参考链接:https://mozillazg.com/2017/08/python-asyncio-note-synchronization-primitives.html异步参考:http://python.jobbole.com/88291/...
2019-05-24 16:29:19 1152
翻译 asyncio 系列五、同步原语—Synchronization Primitives
官网连接:https://docs.python.org/zh-cn/3.7/library/asyncio-sync.html将 Synchronization Primitives 暂且翻译为同步原语,设计目的是为了和线程模块相似。一、Lockclassasyncio.Lock(*,loop=None)为了实现任务之间的互斥,不是线程安全的。用于保证独自使用资源。...
2019-05-24 16:12:55 2361
翻译 asyncio 系列四、期程 — asyncio.Future
asyncio的期程官网链接:https://docs.python.org/zh-cn/3/library/asyncio-future.html#asyncio.Future其实期程指的是,classasyncio.Future返回的实例,官网翻译为期程。一、期程函数asyncio.isfuture(obj)如果obj为下面任意对象,返回Tru...
2019-05-24 16:09:03 2554 1
翻译 asyncio 系列四、asyncio 的异常
异常官网连接:https://docs.python.org/zh-cn/3.7/library/asyncio-exceptions.htmlexceptionasyncio.TimeoutError该操作已超过规定的截止日期。重要:这个异常与内置TimeoutError异常不同。exceptionasyncio.CancelledError该操...
2019-05-24 15:58:02 9160 2
翻译 asyncio 系列三、asyncio 队列
asyncio 队列classasyncio.Queue(maxsize=0,*,loop=None)先进,先出(FIFO)队列如果maxsize小于等于零,则队列尺寸是无限的。如果是大于0的整数,则当队列达到maxsize时,awaitput()将阻塞至某个元素被get()取出。不像标准库中的并发型queue,队列的尺寸一直是已知的,可以通过调用...
2019-05-24 15:54:16 3686
翻译 asyncio 系列二、asyncio 子进程
asyncio的子进程官网连接:https://docs.python.org/zh-cn/3.7/library/asyncio-subprocess.html官网例子:import asyncioasync def run(cmd): proc = await asyncio.create_subprocess_shell( cmd, ...
2019-05-24 15:49:34 4749
翻译 asyncio 系列一、asyncio 的协程与任务
asyncio 的协程与任务官网:https://docs.python.org/zh-cn/3/library/asyncio-task.html#scheduling-from-other-threads一、协程用async定义的函数,可以叫协程函数、异步函数,本文统一叫协程函数。调用协程函数返回的对象叫协程对象。关键字 await 调用协程函数,也可以叫等待、等待调用,这...
2019-05-24 15:46:41 7918
原创 记一次安装python3.7.3
1、默认python3、ipython3、pip的路径 name@host:~$ which python /usr/bin/python name@host:~$ which python3 /usr/bin/python3 name@host:~$ which pip /usr/local/bin/pip name@host:~$ wh...
2019-05-20 15:59:47 4427 3
原创 concurrent.futures调研
concurrent.futures调研参考链接:官网:https://docs.python.org/3.7/library/concurrent.futures.htmlhttps://learnku.com/docs/pymotw/concurrentfutures-manage-pools-of-concurrent-tasks/3424#48d590https://www...
2019-05-20 12:14:12 1045
转载 python获取函数名类名
参考链接:1.在类内部获取类名和方法名代码:import sysclass testsqawd(object): def hello(self): print('the name of method is ## {}##'.format(sys._getframe().f_code.co_name)) print('the name of...
2019-05-18 19:09:21 12844
原创 Python type hints 调研
Python type hints 调研参考链接:官网https://docs.python.org/3/library/typing.htmlhttps://ocavue.com/python_typing.htmlhttps://blog.csdn.net/chuchus/article/details/77891128https://www.cnblogs.com/er...
2019-05-06 16:09:35 1175
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人