Poohl / joycontrol

Emulate Nintendo Switch Controllers over Bluetooth
GNU General Public License v3.0
299 stars 67 forks source link

"RuntimeError: Task does not support set_exception operation" #26

Open MagnusVesper opened 1 year ago

MagnusVesper commented 1 year ago

The run_controller_cli.py script works perfectly for 1 input. But after sending it, the script throws a runtime error. Here is an example after I connected to the switch and simulated a b button press (which registered on the switch)

cmd >> b
[21:38:24] joycontrol.protocol _write::120 INFO - left change Grip/Order menu
[21:38:24] joycontrol.protocol _writer::190 WARNING - Writer exited...
[21:38:24] joycontrol.transport pause_writing::198 INFO - pause transport write
[21:38:24] joycontrol.transport read::94 ERROR - No data received.
[21:38:24] joycontrol.protocol connection_lost::262 ERROR - Connection lost.
[21:38:24] joycontrol.transport pause_writing::198 INFO - pause transport write
[21:38:24] asyncio default_exception_handler::1744 ERROR - Task exception was never retrieved
future: <Task finished name='Task-170' coro=<L2CAP_Transport.close() done, defined at ~/joycontrol-amiibo_edits/joycontrol/transport.py:208> exception=RuntimeError('Task does not support set_exception operation')>
Traceback (most recent call last):
  File "~/joycontrol-amiibo_edits/joycontrol/transport.py", line 224, in close
    await self._read_thread
  File "~/joycontrol-amiibo_edits/joycontrol/transport.py", line 78, in _reader
    await self._protocol.report_received(await self.read(), self._itr_sock.getpeername())
  File "~/joycontrol-amiibo_edits/joycontrol/transport.py", line 95, in read
    self._protocol.connection_lost()
  File "~/joycontrol-amiibo_edits/joycontrol/protocol.py", line 267, in connection_lost
    self._controller_state_sender.set_exception(NotConnectedError)
RuntimeError: Task does not support set_exception operation
[21:38:24] asyncio default_exception_handler::1744 ERROR - Exception in callback create_error_check_callback.<locals>.callback(<Task finishe...n operation')>) at ~/joycontrol-amiibo_edits/joycontrol/utils.py:55
handle: <Handle create_error_check_callback.<locals>.callback(<Task finishe...n operation')>) at ~/joycontrol-amiibo_edits/joycontrol/utils.py:55>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "~/joycontrol-amiibo_edits/joycontrol/utils.py", line 58, in callback
    future.result()
RuntimeError: Task does not support set_exception operation

I then have to kill the script to end it. It doesn't seem to matter how long I wait between connecting and sending the first input. It always works for exactly 1 input then throws this error.

Here is the full output starting from when I called the script: (Note: I replaced the location of the joycontrol folder with ~ above to look cleaner. The text file has the real path.) out.txt

MagnusVesper commented 1 year ago

Here are the steps I took to set up this project: I'm running Arch, so I followed the first bit of the installation guide on the original project this is forked from. That's where the first 2 lines come from.

sudo pacman -S hidapi
yay -S bluez-utils-compat

sudo pip3 install aioconsole hid crc8
sudo nano /lib/systemd/system/bluetooth.service #changed ExecStart line
sudo systemctl daemon-reload
sudo systemctl restart bluetooth.service
#cd into folder I downloaded this to
sudo pip3 install .
8ar10der commented 1 year ago

Same problem with same operations

zhkong commented 1 year ago

I have same problem, do you fix it😂?

bin16 commented 1 year ago

same problem


cmd >> a
[10:33:02] joycontrol.protocol _write::120 INFO - left change Grip/Order menu
[10:33:02] joycontrol.protocol _writer::190 WARNING - Writer exited...
[10:33:03] joycontrol.transport pause_writing::198 INFO - pause transport write
[10:33:03] joycontrol.transport read::94 ERROR - No data received.
[10:33:03] joycontrol.protocol connection_lost::262 ERROR - Connection lost.
[10:33:03] joycontrol.transport pause_writing::198 INFO - pause transport write
[10:33:03] asyncio default_exception_handler::1744 ERROR - Task exception was never retrieved
future: <Task finished name='Task-124' coro=<L2CAP_Transport.close() done, defined at /root/app/joycontrol/joycontrol/transport.py:208> exception=RuntimeError('Task does not support set_exception operation')>
Traceback (most recent call last):
  File "/root/app/joycontrol/joycontrol/transport.py", line 224, in close
    await self._read_thread
  File "/root/app/joycontrol/joycontrol/transport.py", line 78, in _reader
    await self._protocol.report_received(await self.read(), self._itr_sock.getpeername())
  File "/root/app/joycontrol/joycontrol/transport.py", line 95, in read
    self._protocol.connection_lost()
  File "/root/app/joycontrol/joycontrol/protocol.py", line 267, in connection_lost
    self._controller_state_sender.set_exception(NotConnectedError)
RuntimeError: Task does not support set_exception operation
[10:33:03] asyncio default_exception_handler::1744 ERROR - Exception in callback create_error_check_callback.<locals>.callback(<Task finishe...n operation')>) at /root/app/joycontrol/joycontrol/utils.py:55
handle: <Handle create_error_check_callback.<locals>.callback(<Task finishe...n operation')>) at /root/app/joycontrol/joycontrol/utils.py:55>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/root/app/joycontrol/joycontrol/utils.py", line 58, in callback
    future.result()
RuntimeError: Task does not support set_exception operation