uriyyo / pycharm-evaluate-async-code

Finally, you can use await in evaluate expression 💪
https://plugins.jetbrains.com/plugin/14476-evaluate-async-code
44 stars 2 forks source link

Сould you explain how to use it? #1

Closed artas728 closed 4 years ago

artas728 commented 4 years ago

Hello The question in the title, I would really appreciate an answer

uriyyo commented 4 years ago

Hi @artas728,

I thought that will be a great idea to have documentation regarding how to use this plugin but as usual, I haven't enough time to do it. Sorry, my bad 😔

Basically, the only thing you should do is install a plugin in PyCharm, that's all. It will replace default PyCharm debugger with custom one which supports await syntax in evaluate expression and conditional breakpoints (It will patch default asyncio loop using nest-asyncio library in order to have ability reenter to running event loop).

Example

I will show you a quick example, how PyCharm will behave in different cases with and without this plugin.

For instance, we have async code like this:

async def foo(n):
    return n * 2

async def bar():
    for i in range(10):
        n = await foo(I) # At this line we have breakpoint
        print(n)

After we reach a breakpoint, we will open evaluate expression window.

Evaluate expression without plugin

image

Evaluate expression with installed plugin

image

Notes

Also, you can use await syntax in Watchers window and for conditional breakpoints.

uriyyo commented 4 years ago

@artas728 If you have more questions or something isn't clear for you, feel free to ask 😊

artas728 commented 4 years ago

@uriyyo , it is very clear and simple, thanks a lot for the detailed answer!

uriyyo commented 4 years ago

@artas728 great, I will close this issue. In case of any questions, you can reopen an issue.