{"id":93596,"date":"2020-04-10T07:50:18","date_gmt":"2020-04-09T23:50:18","guid":{"rendered":"http:\/\/4563.org\/?p=93596"},"modified":"2020-04-10T07:50:18","modified_gmt":"2020-04-09T23:50:18","slug":"%e6%b1%82%e8%a7%a3%ef%bc%8c-python3-5-%e7%9a%84-asyncio-%e5%ba%93%ef%bc%8c-async-await-%e7%9a%84%e4%b8%80%e4%ba%9b%e7%96%91%e6%83%91","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=93596","title":{"rendered":"\u6c42\u89e3\uff0c python3.5 \u7684 asyncio \u5e93\uff0c async\/await \u7684\u4e00\u4e9b\u7591\u60d1"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u89e3\uff0c python3.5 \u7684 asyncio \u5e93\uff0c async\/await \u7684\u4e00\u4e9b\u7591\u60d1               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fghjghf <\/span>  <span><i><\/i> 20<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>async\/await \u8fd9\u4e2a\u534f\u7a0b \u5f02\u6b65\u4e3a\u4ec0\u4e48\u5bf9\u78c1\u76d8 io \u65e0\u6548\uff1f<\/p>\n<p>import asyncio<br \/> async def wr1(): # f = open(&#8216;text1.txt&#8217;,&#8217;w&#8217;) # for x in range(1,39999999): # f.write(&#8216;12345ddd&#8217;) # f.close()<\/p>\n<pre><code>f = open('text3.txt','r') print(f.read()) f.close() <\/code><\/pre>\n<p>async def wr2(): # f = open(&#8216;text2.txt&#8217;,&#8217;w&#8217;) # for x in range(1,79999999): # f.write(&#8216;23456fff&#8217;) # f.close()<\/p>\n<pre><code>for x in range(1,519999):  print('xx') <\/code><\/pre>\n<p>async def wr3(): # f = open(&#8216;text3.txt&#8217;,&#8217;w&#8217;) # for x in range(1,99999999): # f.write(&#8216;34567ggg&#8217;) # f.close()<\/p>\n<pre><code>for x in range(1,919999):  print('yy') <\/code><\/pre>\n<p>def demo4():<\/p>\n<pre><code>async def washing1():     await wr1()  async def washing2():     await wr2()  async def washing3():     await wr3()   # 1. \u521b\u5efa\u4e00\u4e2a\u4e8b\u4ef6\u5faa\u73af loop = asyncio.get_event_loop()  # 2. \u5c06\u5f02\u6b65\u51fd\u6570\u52a0\u5165\u4e8b\u4ef6\u961f\u5217 tasks = [     washing1(),     washing2(),     washing3(), ]  # 3. \u6267\u884c\u4e8b\u4ef6\u961f\u5217, \u76f4\u5230\u6700\u665a\u7684\u4e00\u4e2a\u4e8b\u4ef6\u88ab\u5904\u7406\u5b8c\u6bd5\u540e\u7ed3\u675f loop.run_until_complete(asyncio.wait(tasks))   # 4. \u5982\u679c\u4e0d\u518d\u4f7f\u7528 loop, \u5efa\u8bae\u517b\u6210\u826f\u597d\u5173\u95ed\u7684\u4e60\u60ef loop.close() <\/code><\/pre>\n<p>if <strong>name<\/strong> == &#8216;<strong>main<\/strong>&#8216;: start = time()<\/p>\n<pre><code> demo4()    end = time() print('elapsed time = ' + str(end - start)) <\/code><\/pre>\n<p>\u7b2c\u4e00\u6bb5\u662f\u8bfb\u53d6\u78c1\u76d8\uff0c\u7b2c\u4e8c\u7b2c\u4e09\u6bb5\u662f\u6253\u5370\u3002\u6309\u9053\u7406\u9047\u5230 io,dma \u4ea4\u51fa\u603b\u7ebf\uff0ccpu \u5c31\u7a7a\u8fd0\u8f6c\u76f4\u5230\u6709\u6570\u636e\u624d\u5de5\u4f5c\uff0c\u6240\u4ee5 wr1 \u5e94\u8be5\u548c 2 \u6216 3 \u4e00\u5757\u6267\u884c\u624d\u5bf9\u7684\uff0c\u800c\u5b9e\u9645\u60c5\u51b5\u4e0d\u662f\u8fd9\u6837\u7684\uff0c\u662f\u8ddf\u5355\u7ebf\u7a0b\u540c\u6b65\u6267\u884c\u4e00\u6837\u7684\u6240\u9700\u65f6\u95f4<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>30<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1154697\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lucahhai <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             washing1()\uff0cwashing2()\uff0cwashing3()\u4e0d\u8981 await wr1()\uff0cwr2(), wr3()\u8fd9\u4e48\u641e\uff0c\u8fd9\u6837\u672c\u6765\u5c31\u548c\u540c\u6b65\u4e00\u6837\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154698\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lniwn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9996\u5148\u4f60\u5f97\u660e\u767d\u534f\u7a0b\u7684\u6982\u5ff5\uff0c\u4e0d\u662f\u52a0\u4e2a async \u4fee\u9970\u5c31\u80fd\u53eb\u5f02\u6b65\u51fd\u6570\u7684\u3002\u5982\u679c\u4f7f\u7528\u4e86 asyncio\uff0c\u90a3 io \u4ee5\u53ca sleep \u7b49\u64cd\u4f5c\uff0c\u5c31\u8981\u4f7f\u7528 asyncio \u5305\u5185\u7684\u5c01\u88c5\u51fd\u6570\u3002\u6216\u8005\u4f7f\u7528 executor \u3002<br \/>\u4f60\u7684\u4ee3\u7801\u91cc open \u64cd\u4f5c\u5361\u6b7b\u6574\u4e2a\u7ebf\u7a0b\uff0c\u5bfc\u81f4\u6ca1\u6cd5 yield \u5230\u5176\u4ed6\u534f\u7a0b\uff0c\u6240\u4ee5\u53ea\u80fd\u987a\u5e8f\u6267\u884c\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154699\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CosimoZi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f\u4f60\u8bf4\u4ed6\u662f\u534f\u7a0b\u5b83\u5c31\u662f\u534f\u7a0b\u7684,\u5b83\u5f97\u662f\u534f\u7a0b\u5b83\u624d\u662f\u4e00\u4e2a\u534f\u7a0b.<br \/>https:\/\/github.com\/Tinche\/aiofiles                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154700\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gwy15 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728\u5f02\u6b65\u51fd\u6570\u91cc\u9762\u8c03\u7528\u540c\u6b65\u51fd\u6570\u8fd8\u662f\u4f1a\u963b\u585e\u7684\u554a\uff0c\u4f60\u5f97\u7528\u5f02\u6b65\u7684\u6587\u4ef6\u63a5\u53e3\u3002\u5b98\u65b9\u5e93\u91cc\u9762\u6ca1\u6709\uff0c\u5f97\u7528\u7ebf\u7a0b\u6c60\uff0c\u6216\u8005\u4f60\u81ea\u5df1\u9020\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154701\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iyaozhen <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u5c31\u662f Python \u8fd9\u4e9b\u8bed\u8a00\u534a\u8def\u51fa\u5bb6\u641e\u534f\u7a0b\u7684\u7f3a\u70b9<\/p>\n<p>\u5e95\u5c42\u5f88\u591a\u4e1c\u897f\u6ca1\u6709\u5f02\u6b65\uff0c\u4e0d\u662f\u7b80\u5355\u52a0\u4e2a async \u5173\u952e\u5b57\u5c31\u89e3\u51b3\u95ee\u9898\u4e86 <\/p>\n<p>\u5176\u5b9e\u76ee\u524d\u7edd\u5927\u90e8\u5206\u5f02\u6b65\u65b9\u6848\u90fd\u65e0\u6cd5\u505a\u5230\u6587\u4ef6 IO \u7684\u5f02\u6b65\uff0c\u90fd\u662f\u7ebf\u7a0b\u6c60\u53bb\u6a21\u62df\u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154702\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iyaozhen <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u770b\u770b\u8fd9\u4e2a https:\/\/github.com\/Tinche\/aiofiles\/                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154703\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : janxin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9700\u8981\u9009\u62e9\u652f\u6301\u5f02\u6b65\u529f\u80fd\u7684 io \u5e93                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154704\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : fghjghf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lniwn \u4e0d\u61c2\u6c42\u89e3\u3002\u90a3\u5c31\u662f\u8bf4\uff0c\u5fc5\u987b\u662f asyncio \u5305\u5185\u5c01\u88c5\u7684\u51fd\u6570\uff0c\u4f8b\u5982 asyncio.sleep(3)\u8fd9\u79cd\u624d\u6709\u7528\u5417\uff1f(\u6211\u4e5f\u6d4b\u8fc7\uff0casyncio.sleep \u51fd\u6570\u7684\u786e\u6709\u6548\uff0c\u4f1a\u5feb\u5f88\u591a\uff0c\u4f46\u8fd9\u4e0d\u662f\u771f\u7684 io \u64cd\u4f5c\u554a)\u3002\u90a3\u9047\u5230\u771f\u7684 io \u64cd\u4f5c\u5982\u4f55\u662f\u597d\uff1f\u5176\u5b9e\u6211\u662f\u60f3\u548c tornado \u642d\u914d\u7528\u7684\u3002tornado6 \u4e0d\u652f\u6301 @gen.coroutine \u4e86\uff0c\u5fc5\u987b\u7528 async\/await \u3002\u6211\u7684\u7406\u89e3 ioloop \u662f\u901a\u8fc7 epoll \u7684 in out error \u975e\u5835\u585e\u505a\u5230\u5355\u7ebf\u7a0b\u9ad8\u5e76\u53d1\u7684\uff0c\u9047\u5230 EAGAIN \u5c31\u7528\u534f\u7a0b\u7ee7\u7eed\u6267\u884c\u53e6\u4e00\u6bb5\u903b\u8f91\u3002\u4e0d\u77e5\u9053\u8fd9\u6837\u7406\u89e3\u662f\u5426\u6709\u9519                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154705\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Trim21 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7f51\u7edc io \u6709\u539f\u751f\u534f\u7a0b\uff0c\u6587\u4ef6 io \u8981\u8981\u534f\u7a0b\u53ea\u80fd\u7528\u7ebf\u7a0b\u5305\u8d77\u6765\uff0c\u6ca1\u6cd5\u539f\u751f\u5f02\u6b65\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154706\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : fghjghf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Trim21 \u4e0d\u61c2\u6c42\u89e3\u3002<br \/>from tornado.web import RequestHandler<br \/>from tornado import gen<br \/>import tornado.ioloop<\/p>\n<p>class IndexHandler(RequestHandler):<br \/> def get(self):<br \/> self.write(&#8216;this is index&#8217;)<\/p>\n<p>class BlockingHandler(RequestHandler):<br \/> async def get(self):<br \/> result = await self.dosomething()<br \/> self.write(result)<\/p>\n<p> async def dosomething(self):<br \/> # \u5982\u679c\u662f\u5176\u4ed6\u5904\u7406\u51fd\u6570\u6216\u8005\u903b\u8f91\uff0c\u8981\u4fdd\u8bc1\u51fd\u6570\u662f\u534f\u7a0b<br \/> await gen.sleep(20)<br \/> return &#8216;block end&#8217;<\/p>\n<p>app = tornado.web.Application([<br \/> (r&#8221;\/index&#8221;, IndexHandler),<br \/> (r&#8221;\/blocking&#8221;, BlockingHandler)<br \/>])<br \/>if __name__ == &#8220;__main__&#8221;:<br \/> app.listen(80)<br \/> tornado.ioloop.IOLoop.instance().start()<\/p>\n<p>\u90a3 async\/await \u7528\u5728 tornado6 \u4e0a\u6709\u5565\u4f5c\u7528\u5462\uff1f\u4e00\u5b9a\u8981 asyncio \u5185\u5305\u88c5\u7684\u51fd\u6570\u624d\u6709\u6548\u3002\u4f46 IOLoop \u5df2\u7ecf\u7528 epoll \u5b9e\u73b0\u7f51\u7edc io \u590d\u7528\u4e86\u3002\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5835\u585e\u7684\u4e0d\u90fd\u662f\u78c1\u76d8 io \u4e48\u3002\u90a3\u8fd9\u4e48\u505a\u7684\u76ee\u7684\u53c8\u662f\u5565\u5462                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154707\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Trim21 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fghjghf #10 io \u590d\u7528\u548c\u5f02\u6b65 io \u662f\u4e24\u4e2a\u6982\u5ff5\u5427\uff0casync\/await \u662f\u4e3a\u4e86\u89e3\u51b3 io \u963b\u585e\uff0c\u4e0d\u8d1f\u8d23\u89e3\u51b3 io \u662f\u5426\u590d\u7528\u7684\u95ee\u9898\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154708\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : fghjghf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Trim21 \u4f46\u7f51\u7edc io \u7684\u5835\u585e\u95ee\u9898\uff0c\u5c01\u88c5 eopll \u7684 ioloop \u5df2\u7ecf\u5e2e\u6211\u4eec\u5904\u7406\u4e86\u3002\u5e95\u5c42\u6709\u4e2a\u961f\u5217\u3002socket \u975e\u5835\u585e\u6267\u884c\uff0cepollin \u548c out \u7684\u65f6\u5019\u624d\u80fd\u5bfb\u627e\u5bf9\u5e94\u8def\u7531\u8868\u6267\u884c\u903b\u8f91\u3002EAGAIN \u5c31 modify epoll \u7684\u72b6\u6001\uff0c\u7ee7\u7eed\u6267\u884c\u961f\u5217\u7684\u4e0b\u4e00\u4e2a\uff0c\u5982\u6b64\u7c7b\u63a8\u3002\u90a3\u5c31\u662f\u80fd\u8d70\u5230\u8def\u7531\u8868\u7684 client socket \u7684\u7f51\u7edc io \u7edd\u5bf9\u662f\u53ef\u7528\u7684\u3002\u6839\u672c\u4e0d\u5b58\u5728\u5835\u585e\u554a\u3002\u90a3 tornado \u4e0a\u7684 async\/await \u5177\u4f53\u6709\u5565\u4f5c\u7528\u5462\uff0c\u4e0d\u77e5\u9053\u6211\u8fd9\u7406\u89e3\u6709\u6ca1\u6709\u9519                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154709\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Trim21 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fghjghf #12 \u8fd9\u4e2a\u662f python \u8bed\u8a00\u5185\u7684\u5f02\u6b65\u3002\u4e4b\u524d python \u540c\u6b65\u8c03\u7528\uff08\u6bd4\u5982 requests.get \uff09\u662f\u6ca1\u6cd5\u5728 io \u963b\u585e\u7684\u65f6\u5019\u8ba9\u51fa\u89e3\u91ca\u5668\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154710\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : PTLin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u65f6\u5019\u5c31\u5f97\u62ff\u51fa\u8fd9\u4e2a\u4e86 https:\/\/hatboy.github.io\/2019\/02\/16\/Python%E5%BC%82%E6%AD%A5%E7%BC%96%E7%A8%8B%E8%AF%A6%E8%A7%A3\/                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154711\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lolizeppelin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u5b66\u4f1a\u8d70\u5c31\u5f00\u59cb\u8dd1\u5c31\u8fd9\u7ed3\u679c\u4e86<\/p>\n<p>\u6b63\u6b63\u7ecf\u7ecf\u7684\u628a\u5f02\u6b65\u7f16\u7a0b\u5199\u51e0\u6b21,\u4ec0\u4e48 select,epoll \u591a\u7ebf\u7a0b\u90fd\u597d\u597d\u7528\u8fc7\u51e0\u6b21\u518d\u6765\u6298\u817e\u534f\u7a0b\u5427<\/p>\n<p>\u522b\u5815\u843d\u5230\u4f4e\u7aef php \u7a0b\u5e8f\u5458\u7684\u6c34\u51c6\u597d\u4e48                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154712\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : neoblackcap <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             async\/await \u672c\u8d28\u4e0a\u662f\u5bf9 IO \u590d\u7528\u673a\u5236\u7684\u5c01\u88c5\uff0c\u7cfb\u7edf\u63d0\u4f9b\u7684 IO \u590d\u7528\u4e0d\u80fd\u5b8c\u6210\u7684\u4e8b\u60c5\uff0casync\/await \u4e5f\u4e0d\u80fd\u5b9e\u73b0\u3002\u6bd4\u5982\u4f60\u60f3\u7528\u5e95\u5c42\u662f epoll \u5b9e\u73b0\u7684 eventloop \u53bb\u5904\u7406\u6587\u4ef6 IO \u90a3\u662f\u4e0d\u884c\u7684\uff0c\u8981\u4e0d\u5c31\u662f\u6a21\u62df\u3002<br \/>\u53bb\u8bfb\u300a Unix \u7f51\u7edc\u7f16\u7a0b\u300b\u5427\uff0c\u56de\u6765\u5c31\u4f1a\u66f4\u597d\u5730\u7406\u89e3\u8fd9\u4e9b\u8bed\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154713\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dreamapple <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             python \u7684\u5f02\u6b65\u4e0d\u5b8c\u5907\u5427\uff0c\u73b0\u5728\u6ca1\u5fc5\u8981\u5728\u4e0a\u9762\u6d6a\u8d39\u65f6\u95f4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154714\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : conn4575 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b98\u65b9 group \u6709\u8ba8\u8bba\u8fc7\u8fd9\u4e2a\u95ee\u9898\uff0c\u7531\u4e8e\u5e95\u5c42\u7cfb\u7edf\u4e0d\u652f\u6301\uff0c\u73b0\u5728\u7684\u5f02\u6b65\u672c\u5730 io \u90fd\u662f\u591a\u7ebf\u7a0b\u5305\u88c5\u7684\uff0c\u5b9e\u9645\u7684\u63d0\u5347\u5f88\u5c0f\uff0c\u6240\u4ee5 asycio \u624d\u6ca1\u6709\u505a\u8fd9\u4e2a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154715\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CzaOrz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8212; async\/await \u8fd9\u4e2a\u534f\u7a0b \u5f02\u6b65\u4e3a\u4ec0\u4e48\u5bf9\u78c1\u76d8 io \u65e0\u6548\uff1f<\/p>\n<p>\u53ef\u4ee5\u770b\u770b\u5b98\u7f51\u6587\u6863\uff0c\u660e\u786e\u8bf4\u4e86\u5bf9\u78c1\u76d8 IO \u4e0d\u652f\u6301\uff0c\u4ed6\u4eec\u63a8\u8350 `loop.run_in_executor`                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154716\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lniwn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fghjghf #8 11\uff0c16\uff0c19 \u5df2\u7ecf\u56de\u7b54\u8fd9\u4e2a\u95ee\u9898\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154717\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Orenoid <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u56e0\u4e3a python \u7684\u534f\u7a0b\u672c\u8d28\u4e0a\u662f\u501f\u52a9 IO \u591a\u8def\u590d\u7528\u6765\u5b9e\u73b0\u5f02\u6b65\u7684\uff0c\u78c1\u76d8 IO \u6ca1\u6709\u76f8\u5e94\u7684\u673a\u5236\u548c\u63a5\u53e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154718\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : fghjghf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lolizeppelin \u4e0d\u770b\u6211\u4e0a\u9762\u7684\u56de\u590d\u5417\uff1f\u5f20\u5634\u5c31\u6765\uff1f\uff1f\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154719\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pmispig <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             python \u7684\u534f\u7a0b\u5c31\u662f\u641e\u7b11\u7684\uff0c\u522b\u82b1\u592a\u591a\u5fc3\u601d\uff0c\u5e95\u5c42\u5927\u90e8\u5206\u4e0d\u652f\u6301\u3002\u6bd4\u5982\u7f51\u7edc io,\u4f60\u7528 socket \u5f04\u5230\u6b7b\u90fd\u4e0d\u80fd\u5f02\u6b65\uff0c\u4f60\u5f97\u7528 <br \/>asyncio.open_connection(host,22)\uff0c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154720\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @pmispig &#8230; asyncio.XXX \u4e5f\u662f socket \u554a\uff0c\u4e0d\u662f socket \u5e93\u7684\u624d\u662f socket \u554a\u3002\u4f60\u8fd9\u6279\u5224\u6beb\u65e0\u9053\u7406\u554a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154721\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @pmispig \u5c31\u597d\u50cf\u4f60\u7528 java\uff0c\u7528\u57fa\u7840 socket \u5b83\u4e5f\u4e00\u6837\u4e0d\u5f02\u6b65\u5440\u3002\u4f60\u5f97\u7528\u5f02\u6b65\u6846\u67b6\u6bd4\u5982 vert.x                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154722\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pmispig <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ipwx \u770b\u4f60\u8ddf\u4ec0\u4e48\u6bd4\uff0c\u4f60\u7528 go \u7684\uff0c\u6700\u57fa\u7840\u7684 net.Conn \u5c31\u662f\u652f\u6301\u7684\uff0cpython \u8981\u662f\u4e0d\u80fd\u8ba9 socket \u652f\u6301\uff0c\u90a3\u5f02\u6b65\u6709\u4e2a\u6bdb\u7528\u5462\uff0c\u73b0\u5728\u8fd9\u4e48\u591a\u5e93\u90fd\u662f\u57fa\u4e8e socket,\u5f97\u8981\u4eba\u5bb6\u5168\u90e8\u91cd\u5199                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154723\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @pmispig<\/p>\n<p>go \u65b0\u51fa\u6765\u4e86\uff0c\u5927\u5bb6\u8981\u9020\u65b0\u7c7b\u5e93\uff0c\u53ef\u4ee5\u8fd9\u6ca1\u95ee\u9898\u3002<\/p>\n<p>asyncio \u65b0\u51fa\u6765\u4e86\uff0c\u5927\u5bb6\u8981\u9020\u65b0\u7c7b\u5e93\uff0c\u4e0d\u884c\u8fd9\u5f88\u5783\u573e\u3002<\/p>\n<p>\u4e0d\u89c9\u5f97\u8fd9\u4e48\u8bc4\u4ef7\u5f88\u5947\u602a\u4e48\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154724\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : youxiachai <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3a\u5565\u5b81\u613f\u53d1\u5e16\u90fd\u4e0d\u770b\u770b\u5b98\u65b9\u6587\u6863&#8230;<br \/>https:\/\/github.com\/python\/asyncio\/wiki\/ThirdParty#filesystem<br \/>\u6211\u4e00\u4e2a\u4e0d\u641e python \u90fd\u80fd\u627e\u5230\u7b54\u6848&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154725\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sikong31 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u9700\u8981\u5e93\u4e13\u95e8\u652f\u6301,\u6bd4\u5982 requests \u4e0d\u884c\u5f97\u7528 aiohttp<br \/>\u4e0d\u50cf\u591a\u7ebf\u7a0b,\u76f4\u63a5\u5f80\u91cc\u9762\u653e\u5c31\u884c\u4e86,\u591a\u7ebf\u7a0b\u8be5\u963b\u585e\u7684\u8fd8\u662f\u963b\u585e,\u53ea\u4e0d\u8fc7\u4e0d\u5728\u4e00\u4e2a\u7ebf\u7a0b<br \/>\u534f\u7a0b\u662f\u963b\u585e\u7684\u65f6\u5019\u76f4\u63a5\u8f6c\u5411 loop \u91cc\u7684\u4e0b\u4e00\u4e2a\u4efb\u52a1,\u6240\u4ee5\u8fd9\u91cc\u9762\u5c31\u6709\u4e00\u4e2a\u64cd\u4f5c,\u5c31\u662f\u544a\u8bc9\u7cfb\u7edf\u4f60\u5f85\u4f1a\u513f\u6765\u627e\u6211,<br \/>\u666e\u901a\u7684\u5e93\u5e76\u6ca1\u6709\u8fd9\u4e2a\u64cd\u4f5c,\u53ea\u4f1a\u8ba9\u4f60\u7b49\u7740<br \/>\u5c31\u50cf\u4e70\u4e1c\u897f,\u6709\u4e9b\u4eba\u4f60\u80fd\u6253\u4e2a\u62db\u547c,\u5f85\u4f1a\u7b49\u505a\u5b8c\u4e86\u6765\u53d6\u4e1c\u897f,\u6709\u4e9b\u53ea\u80fd\u7b49\u7740\u4e0d\u80fd\u8d70                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1154726\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @pmispig #26 \u8ddf go \u6bd4\u5f02\u6b65\u652f\u6301\u90a3\u662f\u4f5c\u6b7b\uff0c\u6574\u4e2a\u8bed\u8a00\u8bbe\u8ba1\u548c\u8fd0\u884c\u65f6\u8bbe\u8ba1\u5c31\u662f\u60f3\u7740\u5f02\u6b65\u6765\u7684\u3002<br \/>\u4f60\u6709\u672c\u4e8b\u8ddf erlang \u6bd4\u5206\u5e03\u5f0f\u7cfb\u7edf\u554a\uff0cgo \u8fd8\u8981 grpc\uff0c\u90a3\u4e4b\u524d\u7528 xmlrpc \u7684\u90a3\u4e9b\u662f\u4e0d\u662f\u90fd\u5f97\u91cd\u5199\uff1f<br \/>\u4f55\u51b5\u8fd9\u53eb\u534f\u7a0b\uff0c\u4e00\u4e2a\u4e0d\u63a5\u53d7\u534f\u8c03\u7684\u7a0b\u5e8f\u653e\u91cc\u9762\u4e0d\u80fd\u5982\u4f60\u60f3\u8c61\u5730\u8fd0\u4f5c\uff0c\u4e0d\u662f\u5f88\u7b26\u5408\u8bed\u4e49\u5417\uff1f<\/p>\n<p>\u4f60\u9700\u8981\u7684\u662f gevents \u5427\u2026\u2026                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u89e3\uff0c python3.5 \u7684 a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93596"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93596"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93596\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93596"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}