asyncio socket 的接收问题

2017-10-25 17:53:17 +08:00
 ray1888

我使用官方 tutourial 的 18.5.5.7.2. TCP echo server using streams url 是 https://docs.python.org/3/library/asyncio-protocol.html

然后发送一堆 4 个 json 数据,但是这个 tutourial 只能无限循环第一个,这是为什么呢?

接收结果: {"duration": 6909, "timestamp": 1508925087312791, "annotations": [{"host": null, "value": "GET", "key": "http.method", "annotation_type": 6}, {"host": null, "value": "http://localhost:8081/format", "key": "http.url", "annotation_type": 6}], "name": "formatString", "parent_id": 2405405279606511970}{"duration": 5586, "timestamp": 1508925087320016, "annotations": [{"host": null, "value": "GET", "key": "http.method", "annotation_type": 6}, {"host": null, "value": "http://localhost:8082/publish", "key": "http.url", "annotation_type": 6}], "name": "printHello", "parent_id": 2405405279606511970}{"duration": 13221, "timestamp": 1508925087312715, "annotations": [{"host": null, "value": "const", "key": "sampler.type", "annotation_type": 6}, {"host": null, "value": "True", "key": "sampler.param", "annotation_type": 6}, {"host": null, "value": "Python-3.6.1", "key": "jaeger.version", "annotation_type": 6}, {"host": null, "value": "workvm", "key": "jaeger.hostname", "annotation_type": 6},

发送的数据为: {'duration': 6909, 'timestamp': 1508925087312791, 'annotations': [{'host': None, 'value': 'GET', 'key': u'http.method', 'annotation_type': 6}, {'host': None, 'value': 'http://localhost:8081/format', 'key': u'http.url', 'annotation_type': 6}], 'name': u'formatString', 'parent_id': 2405405279606511970}

{'duration': 5586, 'timestamp': 1508925087320016, 'name': u'printHello', 'parent_id': 2405405279606511970, 'annotations': [{'host': None, 'key': u'http.method', 'value': 'GET', 'annotation_type': 6}, {'host': None, 'key': u'http.url', 'value': 'http://localhost:8082/publish', 'annotation_type': 6}]}

{'duration': 13221, 'timestamp': 1508925087312715, 'name': u'say-hello', 'parent_id': None, 'annotations': [{'host': None, 'key': u'sampler.type', 'value': 'const', 'annotation_type': 6}, {'host': None, 'key': u'sampler.param', 'value': 'True', 'annotation_type': 6}, {'host': None, 'key': u'jaeger.version', 'value': 'Python-3.6.1', 'annotation_type': 6}, {'host': None, 'key': u'jaeger.hostname', 'value': 'workvm', 'annotation_type': 6}, {'host': None, 'key': u'hello-to', 'value': 'yyy123', 'annotation_type': 6}]}

{

1620 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/400689

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX