Asyncio Graph is empty

Answered

Hello,

I have been writing async code and wanted to visualise the concurrency, however the Asyncio graph is completely empty. Initially, I thought that there is something wrong my code, so I used some example snippets and the result was still the same, i.e an empty graph. Snippet:

import aiohttp
import asyncio
import async_timeout

async def fetch(session, url):
    async with async_timeout.timeout(10):
        async with session.get(url) as response:
            return await response.text()

async def main():
    async with aiohttp.ClientSession() as session:
        html = await fetch(session, 'http://python.org')
        print(html)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Is that function working or I am not doing something properly?

 

Edit: I am using PyCharm Professional 2018.1

4 comments
Comment actions Permalink

Hello,

I'm currently diving into asyncio and wanted to try this PyCharm feature. Unfortunately, I have the exact same issue.

My system:

Python 3.6 (virtualenv)

PyCharm 2018.2.4 (Professional Edition)
Build #PY-182.4505.26, built on September 19, 2018
JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14 Mojave


The asyncio graph remains empty ('Nothing to show'). Here's my test code for the asyncio graph:

import asyncio


async def mycoro():
await asyncio.sleep(5)


loop = asyncio.get_event_loop()
task = asyncio.ensure_future(mycoro())
loop.run_until_complete(task)


The threading graph works as expected with the following code:

import time
import threading


def run():
time.sleep(5)


t = threading.Thread(target=run)
t.start()

t.join()


Some additional notes:

- The 'Debug' tab is not visible while the the python script is running. I also can't access it with CMD+5. So it's impossible to watch the stdout of the script. Once the script exits, the Debug tab reappears. - Edit: Found an issue for this: https://youtrack.jetbrains.com/issue/PY-18409
- Different from the 'Run' mode, the 'Concurrent Activities Diagram' doesn't open up automatically after starting the python script. I have to click it manually. - Edit: This probably will be fixed in 2018.3: https://youtrack.jetbrains.com/issue/PY-28178

 

@Stanislav Did you manage to get this diagram to work?

 

Edit: It does work in the PyCharm 2018.3 EAP.

See this issue: https://youtrack.jetbrains.com/issue/PY-29644

0
Comment actions Permalink

Hi Florian,

Is it correct that your problem is solved in EAP build?

-1
Comment actions Permalink

Hi Sergey,

yes, the asyncio diagram works as expected in the 2018.3 EAP build. And it opens up automatically after starting.

But one issue remains: The console output of the script is not visible while running. When stopped, you can go to the Debug tab and see the output. But while the concurrency diagram runs, the debug tab is inaccessible: https://youtrack.jetbrains.com/issue/PY-18409

0
Comment actions Permalink

Thanks for letting me know.

Yes, it is indeed a corresponding issue for that problem. Thanks for posting it here.

-1

Please sign in to leave a comment.