You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/12/11 19:43:09 UTC
[GitHub] [skywalking-python] tom-pytel edited a comment on pull request #100: [WIP] started on aiohttp
tom-pytel edited a comment on pull request #100:
URL: https://github.com/apache/skywalking-python/pull/100#issuecomment-743385592
Here is a very async test snippet:
```py
import asyncio
import aiohttp
from skywalking import agent
from skywalking.decorators import trace
from skywalking.trace.context import get_context
import skywalking.trace.context as context
cities = ['paris', 'lyon', 'nice']
agent.start()
async def child(i):
async with aiohttp.ClientSession() as session:
url = f"https://geo.api.gouv.fr/communes?nom={cities[i]}&fields=nom,region&format=json&geometry=centr"
async with session.get(url) as response:
return await response.json()
loop = asyncio.get_event_loop()
with get_context().new_local_span('/parent'):
loop.run_until_complete(
asyncio.gather(
*(trace(f'child{i}')(child)(i) for i in range(3))
)
)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org