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

Doesn't work with python 3.11.1 #59

Closed neostimul closed 1 year ago

neostimul commented 1 year ago

Hello, thank You for your product. It's very helpful.

Got an error on running Python Console with python3.11.1 In asyncio module, get_event_loop method, a 682 row of asyncio/events.py

  File "<string>", line 339, in <module>
  File "<string>", line 310, in patch_asyncio
  File "<string>", line 16, in apply
  File "<string>", line 45, in _get_event_loop
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/events.py", line 682, in get_event_loop
    if not (module == 'asyncio' or module.startswith('asyncio.')):
                                   ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'
uriyyo commented 1 year ago

Hi @neostimul,

New version 1.21 has been released. This issue should be fixed now.

neostimul commented 1 year ago

Unfortunately, I get the same error. I updated the plugin to 1.21 (and to 1.22 too) before testing

uriyyo commented 1 year ago

Could you please provide the code that you are using, cause I can't reproduce this issue on my local env

neostimul commented 1 year ago

error in row if not (module == 'asyncio' or module.startswith('asyncio.')): python3.11.1/asyncio/events.py:682 module variable is None

class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
    """Default policy implementation for accessing the event loop.

    In this policy, each thread has its own event loop.  However, we
    only automatically create an event loop by default for the main
    thread; other threads by default have no event loop.

    Other policies may have different rules (e.g. a single global
    event loop, or automatically creating an event loop per thread, or
    using some other notion of context to which an event loop is
    associated).
    """

    _loop_factory = None

    class _Local(threading.local):
        _loop = None
        _set_called = False

    def __init__(self):
        self._local = self._Local()

    def get_event_loop(self):
        """Get the event loop for the current context.

        Returns an instance of EventLoop or raises an exception.
        """
        if (self._local._loop is None and
                not self._local._set_called and
                threading.current_thread() is threading.main_thread()):
            stacklevel = 2
            try:
                f = sys._getframe(1)
            except AttributeError:
                pass
            else:
                while f:
                    module = f.f_globals.get('__name__')
                    if not (module == 'asyncio' or module.startswith('asyncio.')):
                        break
                    f = f.f_back
                    stacklevel += 1
            import warnings
            warnings.warn('There is no current event loop',
                          DeprecationWarning, stacklevel=stacklevel)
            self.set_event_loop(self.new_event_loop())

        if self._local._loop is None:
            raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)

        return self._local._loop
uriyyo commented 1 year ago

Hi @neostimul

New version 1.23 has been released.

I hope this issue should be fixed now because a plugin no longer uses nest-asycnio library.

uriyyo commented 1 year ago

Hi @neostimul, Any updates?

neostimul commented 1 year ago

Hi! Thanks a lot. Now everything works great!

uriyyo commented 1 year ago

Thanks for update!