Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorry, AREPL has ran into an error - probably macOS #387

Open
jbarlow83 opened this issue Apr 12, 2021 · 11 comments
Open

Sorry, AREPL has ran into an error - probably macOS #387

jbarlow83 opened this issue Apr 12, 2021 · 11 comments
Labels
bug Something isn't working has-workaround

Comments

@jbarlow83
Copy link

Describe the bug

Sorry, AREPL has ran into an error

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
    key = self._selector.get_key(fd)
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 193, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '5 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jb/.vscode/extensions/almenon.arepl-2.0.2/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 298, in main
    return_info = exec_input(execArgs)
  File "/Users/jb/.vscode/extensions/almenon.arepl-2.0.2/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 234, in exec_input
    asyncio.set_event_loop(asyncio.new_event_loop())
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
    self._make_self_pipe()
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
    self._add_reader(self._ssock.fileno(), self._read_from_self)
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 523, in register
    self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects

Print Output:
Exception ignored in: <function BaseEventLoop.__del__ at 0x11871de50>
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 683, in __del__
    self.close()
  File "/usr/local/Cellar/python@3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 60, in close
    for sig in list(self._signal_handlers):
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'

To Reproduce
Try typing a small program. Probably triggerable by any use of macOS and AREPL when typing a variable name that does not exist yet.

Screenshots
If applicable, add screenshots to help explain your problem.

Other Information (please complete the following information):

  • OS: macOS Mojave
  • Python Version 3.9.2_4 Homebrew
@Almenon
Copy link
Owner

Almenon commented Apr 14, 2021

I'm not able to reproduce on 3.9 w/ windows. Maybe it's a mac-specific bug?

Can you try running the following in the terminal using python 3.9 please and let me know the output?

from sys import version
print(version)
import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())

Related error: eventlet/eventlet#670

I wonder if this is a internal python bug 🤔

@jbarlow83
Copy link
Author

Works fine:

In [1]: from sys import version
   ...: print(version)
   ...: import asyncio
   ...: asyncio.set_event_loop(asyncio.new_event_loop())
3.9.2 (default, Mar 26 2021, 22:33:29)
[Clang 11.0.0 (clang-1100.0.33.17)]

@Almenon
Copy link
Owner

Almenon commented Apr 14, 2021

What about

from sys import version
print(version)
import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())
asyncio.set_event_loop(asyncio.new_event_loop())

?

@jbarlow83
Copy link
Author

No issue/same output.

@Almenon
Copy link
Owner

Almenon commented Apr 17, 2021

I tried to reproduce this on mac el capitan and was unable too. Unfortunately I don't have a mojave-compatible computer so I'm not able to try it there.

How did you run python in the terminal? Can you prefix that command with which so I can see where the executable is please? I'm wondering if the python you're using on the terminal is the same brew python you're using in arepl.

@Almenon
Copy link
Owner

Almenon commented Apr 17, 2021

Oh also if you use a earlier version of python does it work with AREPL?

@BrandonNav
Copy link

BrandonNav commented Apr 29, 2021

What about

from sys import version
print(version)
import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())
asyncio.set_event_loop(asyncio.new_event_loop())

?

I managed to get this working by changing https://github.com/Almenon/AREPL-backend/blob/master/python/arepl_python_evaluator.py#L234

from asyncio.set_event_loop(asyncio.new_event_loop())

to asyncio.set_event_loop(asyncio.get_event_loop())

My environment:
MacOS 11.2.3 (Big Sur)
Python 3.9.3

@Almenon
Copy link
Owner

Almenon commented May 3, 2021

Really? Very interesting... I'll look into this, thanks!

While I was investigating I also ran into another error: Almenon/AREPL-backend#167

Looks like I have some work to do :|

@p-clements
Copy link

p-clements commented Jun 20, 2021

I've experienced the same bug whilst running a simple script using homebrew Python 3.9.5
However, running the same script on homebrew 3.8.10 works just fine.

Running your script above works fine on both 3.9.5 and 3.8.10

Mac OS 10.15.7 (Catalina)
VSCode 1.57.1

Sorry, AREPL has ran into an error

Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
key = self._selector.get_key(fd)
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 193, in get_key
raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '7 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/user1/.vscode/extensions/almenon.arepl-2.0.2/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 298, in main
return_info = exec_input(execArgs)
File "/Users/user1/.vscode/extensions/almenon.arepl-2.0.2/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 234, in exec_input
asyncio.set_event_loop(asyncio.new_event_loop())
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
return get_event_loop_policy().new_event_loop()
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
return self._loop_factory()
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 54, in init
super().init(selector)
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 61, in init
self._make_self_pipe()
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
self._add_reader(self._ssock.fileno(), self._read_from_self)
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
self._selector.register(fd, selectors.EVENT_READ,
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 523, in register
self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects

Print Output:
Exception ignored in: <function BaseEventLoop.del at 0x104700b80>
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 683, in del
self.close()
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 60, in close
for sig in list(self._signal_handlers):
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
Variables:
{}

@pkirkovsky
Copy link

pkirkovsky commented Jul 6, 2021

I'm able to reproduce this reliably using just an import statement.
Reverting to Python 3.7.11 makes it work again, as does using Brandon's asyncio.set_event_loop(asyncio.get_event_loop()) fix on 3.9.6.

Environment

OS X 10.13.6
AREPL 2.0.2
VSCodium Version: 1.57.1
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-18T00:16:36.917Z (2 wks ago)
Electron: 12.0.7
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Darwin x64 17.7.0

Steps to reproduce

  1. Create a python file
  2. Open the AREPL pane
  3. Type import requests
  4. Press the Enter key or spacebar
  5. Open and close the ARPL pane
  6. Add a new line: print('hello')
  7. Press the Enter key or spacebar
arepl_keyerror.mp4

If AREPL is restarted, it throws an error when new code is entered (but not when newlines are added). In my case, the KeyError usually mentions key 5, 8, or 11.

Print Output:
3.9.6 (default, Jul  4 2021, 23:21:00) 
[Clang 9.1.0 (clang-902.0.39.2)]
Exception ignored in: <function BaseEventLoop.__del__ at 0x10bd6ed30>
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 683, in __del__
    self.close()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 58, in close
    super().close()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 92, in close
    self._close_self_pipe()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 99, in _close_self_pipe
    self._remove_reader(self._ssock.fileno())
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 284, in _remove_reader
    self._selector.unregister(fd)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 539, in unregister
    self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects
Variables:
-{
    version: +"3.9.6 (default, Jul 4 2021, 23:21:00) [Clang 9.1.0 (clang-902.0.39.2 ..."
}
57 ms

report an issue | ⭐ rate me ⭐ | talk on gitter | Tweet #arepl
Sorry, AREPL has ran into an error

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
    key = self._selector.get_key(fd)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 193, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '11 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/pavel/.vscode-oss/extensions/almenon.arepl-2.0.2/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 298, in main
    return_info = exec_input(execArgs)
  File "/Users/pavel/.vscode-oss/extensions/almenon.arepl-2.0.2/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 234, in exec_input
    asyncio.set_event_loop(asyncio.new_event_loop())
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
    self._make_self_pipe()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
    self._add_reader(self._ssock.fileno(), self._read_from_self)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 523, in register
    self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects

Print Output:
Exception ignored in: <function BaseEventLoop.__del__ at 0x1025d6d30>
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 683, in __del__
    self.close()
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 60, in close
    for sig in list(self._signal_handlers):
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
Variables:
{}
0 ms

report an issue | ⭐ rate me ⭐ | talk on gitter | Tweet #arepl

@Almenon
Copy link
Owner

Almenon commented May 31, 2022

Finally got access to a Mac. I can reproduce the bug on 3.9, but the bug does not occur on 3.10. I suggest either using the fix workaround above, downgrading to 3.7, or upgrading to 3.10.

The other interesting thing is that for me this only occurs in the third arepl run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has-workaround
Projects
None yet
Development

No branches or pull requests

5 participants