rndusr / stig

TUI and CLI for the BitTorrent client Transmission
GNU General Public License v3.0
554 stars 24 forks source link

"RuntimeError: Event loop stopped before Future completed." when quitting #188

Closed 0xC0ncord closed 3 years ago

0xC0ncord commented 3 years ago

v0.11.2a0 (python3.8) gives me this error every time I quit the application:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.8/stig", line 33, in <module>
    sys.exit(load_entry_point('stig==0.11.2a0', 'console_scripts', 'stig')())
  File "/usr/lib/python3.8/site-packages/stig/__init__.py", line 25, in run
    main.run()
  File "/usr/lib/python3.8/site-packages/stig/main.py", line 105, in run
    asyncio.get_event_loop().run_until_complete(srvapi.rpc.disconnect('Quit'))
  File "/usr/lib/python3.8/asyncio/base_events.py", line 614, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.

This isn't really a big deal, but it's pretty noisy.

rndusr commented 3 years ago

I noticed that, too. I successfully fixed that bug by kicking it down the road until Python 3.9 came out and it vanished into thin air.

I don't have to time to debug this unless it's more than annoying.

0xC0ncord commented 3 years ago

I successfully fixed that bug by kicking it down the road until Python 3.9 came out and it vanished into thin air.

Hah. I'm not really bothered by this bug so I don't mind closing it, but maybe it should stay open for visibility or until there's a proper fix?

rndusr commented 3 years ago

Yeah, sure.

yookoala commented 3 years ago

I am using Python 3.9.1 but I still see this error when quitting. I installed stig with pip instead of pipx. Not sure if this is relevant.

stig version 0.11.2a0

The full message I got:

Traceback (most recent call last):
  File "/home/foobar/.local/bin/stig", line 8, in <module>
    sys.exit(run())
  File "/home/foobar/.local/lib/python3.9/site-packages/stig/__init__.py", line 25, in run
    main.run()
  File "/home/foobar/.local/lib/python3.9/site-packages/stig/main.py", line 105, in run
    asyncio.get_event_loop().run_until_complete(srvapi.rpc.disconnect('Quit'))
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 640, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.
rndusr commented 3 years ago

Weird. I can reproduce this with the pyenv Python but not with my system Python.

Anyway, it looks like the fix was pretty easy. Let's hope this doesn't blow up anything else.

yookoala commented 3 years ago

Just checked out stig-0.12.0a0 and confirm the issue is fixed.

rndusr commented 3 years ago

Just checked out stig-0.12.0a0 and confirm the issue is fixed.

Thanks.

rndusr commented 3 years ago

With my fix I'm getting an "Unclosed client session" when not using the TUI (stig ls foo).

I think I've found a fix that solves both issues, but I'm having a hard time reproducing the original issue reliably.

Can someone pull from master and confirm that stig and stig ls foo don't produce any unexpected output?

yookoala commented 3 years ago

Just tried this:

$ git clone https://github.com/rndusr/stig.git
$ cd stig
$ python3 -m stig ls foo
list: No matching torrents: ~foo
$ python3 -m stig

When I quit by q, the error message is still gone.

Just to be sure, I then checkout v0.11.2a0 to test the q command. I successfully reprodued the previous issue:

$ git checkout v0.11.2a0
Note: switching to 'v0.11.2a0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 7ab3df0c Bump version

$ python3 -m stig
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/foobar/stig/stig/__main__.py", line 17, in <module>
    run()
  File "/home/foobar/stig/stig/__init__.py", line 25, in run
    main.run()
  File "/home/foobar/stig/stig/main.py", line 105, in run
    asyncio.get_event_loop().run_until_complete(srvapi.rpc.disconnect('Quit'))
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 640, in run_until_complete
    raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.

So that proofs I'm actually using the code in the folder. Is that enough?

rndusr commented 3 years ago

Yes, looks great. Thank you.