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

pyee error | exception calling callback for <Future at 0x737d75f0 state=finished raised KeyError> #2695

Closed
Y0ngg4n opened this issue Sep 16, 2020 · 11 comments

Comments

@Y0ngg4n
Copy link

Y0ngg4n commented Sep 16, 2020

How to submit an Issue to a Mycroft repository

When submitting an Issue to a Mycroft repository, please follow these guidelines to help us help you.

Be clear about the software, hardware and version you are running

For example:

  • I'm running Picroft
  • With latest version
  • With the standard Wake Word

Try to provide steps that we can use to replicate the Issue

For example:

  1. Open mycroft cli
  2. wait (it comes every ca. 30 seconds)

Provide log files or other output to help us see the error

20:00:14.407 | ERROR | 949 | concurrent.futures | exception calling callback for <Future at 0x737d7b10 state=finished raised KeyError>Traceback (most recent call last): File "/usr/lib/python3.7/concurrent/futures/_base.py", line 324, in _invoke_callbacks callback(self) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_executor.py", line 60, in _callback self.emit('error', exc) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 111, in emit self._emit_handle_potential_error(event, args[0] if args else None) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 83, in _emit_handle_potential_error raise error File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 121, in g self.remove_listener(event, f) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 136, in remove_listener self._events[event].pop(f)KeyError: <bound method MessageWaiter._handler of <mycroft.messagebus.client.client.MessageWaiter object at 0xb2e8fd90>> 20:00:14.408 | ERROR | 949 | concurrent.futures | exception calling callback for <Future at 0x737d79d0 state=finished raised KeyError>Traceback (most recent call last): File "/usr/lib/python3.7/concurrent/futures/_base.py", line 324, in _invoke_callbacks callback(self) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_executor.py", line 60, in _callback self.emit('error', exc) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 111, in emit self._emit_handle_potential_error(event, args[0] if args else None) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 83, in _emit_handle_potential_error raise error File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 121, in g self.remove_listener(event, f) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/pyee/_base.py", line 136, in remove_listener self._events[event].pop(f)KeyError: <bound method MessageWaiter._handler of <mycroft.messagebus.client.client.MessageWaiter object at 0x7514b7b0>>

image

@forslund
Copy link
Collaborator

Could you try to set the log level to debug by entering the cli command :log level debug to see if it gives any more info what it tries to do right be fore the error there?

It looks like an error shown when the wait_for_response() or wait_for_message() tries to remove a handler that's already been removed. Will see if I can provoke it to happening.

@Y0ngg4n
Copy link
Author

Y0ngg4n commented Sep 17, 2020

Screen Capture_deepin-terminal_20200917141521
Screen Capture_deepin-terminal_20200917141536
Screen Capture_deepin-terminal_20200917141604

@forslund
Copy link
Collaborator

Darn, no additional info if I'm reading those screenshots correctly. I couldn't reproduce it yesterday but will try some more.

@Y0ngg4n
Copy link
Author

Y0ngg4n commented Sep 17, 2020

@forslund sorry :/

@j1nx
Copy link

j1nx commented Sep 29, 2020

Just an idea here. If the user or some skill installs the "mycroft-messagebus-client" pip package, there is a pyee version conflict as the messagebus-client is still using pyee==5.0.1

MycroftAI/mycroft-messagebus-client#4

I am seeing that when installing systemwide as --user option. Not sure if it also occurs within a venv. Perhaps it is related as it is about pyee.

@forslund
Copy link
Collaborator

If that happens I do believe (after testing) the errors occurring would be ImportErrors since the ExecutorEventEmitter class isn't available.

@krisgesling
Copy link
Contributor

After some more probing and chatting with Ake, I think this might be the MessageBusClient.emitter.once method attempting to pop the callback function off an event that has already been cleared.

We still need to verify this and if true, perhaps ensure that each function registered is unique.

@forslund
Copy link
Collaborator

forslund commented Oct 5, 2020

So I did some testing and each function registered is unique. I think the issue here is non-fatal since the exception is catched and reported.

My tests makes me believe the issue is a race condition between the timeout (which removes the handler) and the pyee once automatic removal of the handler. This may be something that we need to report upstream to pyee...

I've seen the error myself randomly and added some extra logging to see if I can pinpoint where in mycroft's code it gets triggered. Somewhere in the skills process...

@forslund
Copy link
Collaborator

forslund commented Oct 7, 2020

I opened an issue upstream.

@forslund
Copy link
Collaborator

forslund commented Oct 8, 2020

Ok a fix to my theoretical observation has been merged in pyee and released as 8.1.0. I'll prepare a PR here and on Adapt to get the versions synced and we'll see if that resolves the issue. Otherwise there's some other issue as well :)

@forslund
Copy link
Collaborator

Hi, I'm going to close this issue for now. The proposed update to resolved this has been accepted upstream and Mycroft has included it.

In addition the functionality handling this has been moved out from core into mycroft-messagebus-client. If you're still seeing this issue please reopen the issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Roadmap
  
Inbox
Development

No branches or pull requests

4 participants