异步多进程通信管道

aiopipe的Python项目详细描述


aiopipe—用于异步的多进程通信管道

Documentation

这个包包装^{} 单工通信管,可作为非阻塞的一部分 ^{}事件循环。

示例

下面的示例打开一个管道,子进程中的write端和read端 在父进程中结束:

fromcontextlibimportclosingfrommultiprocessingimportProcessimportasynciofromaiopipeimportaiopipeasyncdefmainTask(eventLoop):rx,tx=aiopipe()withtx.send()astx:proc=Process(target=childProc,args=(tx,))proc.start()# The write end is now available in the child process# and invalidated in the parent process.stream=awaitrx.open(eventLoop)msg=awaitstream.readline()assertmsg==b"hi from child process\n"proc.join()defchildProc(tx):eventLoop=asyncio.new_event_loop()stream=eventLoop.run_until_complete(tx.open(eventLoop))withclosing(stream):stream.write(b"hi from child process\n")eventLoop=asyncio.get_event_loop()eventLoop.run_until_complete(mainTask(eventLoop))

安装

此软件包要求python>;=3.5.0,可以使用pip

安装
pip install aiopipe

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在通过url读取csv文件时,我想用数据映射列名   java在没有类型转换的情况下访问父类型的arraylist中的特定子类型方法,子类型的创建只有在运行时才知道   java扩展UIComponentBase时如何保存状态   java如何使用字符串作为Velocity模板?   用于调试远程/本地java应用程序的自定义调试器   JavaFx和浮动按钮   java如何修改列表中的对象?在迭代时扩展MyObject>?   java Spring框架如何避免控制器中的重复代码?   java代码名1 IOS签名   一点Bitly API有Java库吗?   jasper报告将Highcharts图表添加到使用JavaAPI生成的JasperReport模板中   swing如何在java中更改按键的颜色   java Javax Websocket使用路径参数提交登录数据,好的做法?