Freeze with "cannot schedule new futures after shutdown"
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.6k
- Forks
- 3.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 61
Description
On Debian Bullseye, with python 3.9.2, electrum 4.1.5 (running from sources) can freeze with "cannot schedule new futures after shutdown" logged repeatedly. QT UI became unresponsive and I had to kill the process manually. I hit this while trying to create a hardware wallet (see below for more detail):
Traceback (most recent call last):
File "/home/user/src/github.com/spesmilo/electrum/electrum/util.py", line 1120, in wrapper
return await func(*args, **kwargs)
File "/home/user/src/github.com/spesmilo/electrum/electrum/interface.py", line 487, in wrapper_func
return await func(self, *args, **kwargs)
File "/home/user/src/github.com/spesmilo/electrum/electrum/interface.py", line 510, in run
await self.open_session(ssl_context)
File "/home/user/src/github.com/spesmilo/electrum/electrum/interface.py", line 657, in open_session
await group.spawn(self.monitor_connection)
File "/home/user/.local/lib/python3.9/site-packages/aiorpcx/curio.py", line 255, in __aexit__
await self.join()
File "/home/user/.local/lib/python3.9/site-packages/aiorpcx/curio.py", line 213, in join
raise task.exception()
File "/home/user/src/github.com/spesmilo/electrum/electrum/synchronizer.py", line 83, in _run_tasks
await group.spawn(self.main())
File "/home/user/.local/lib/python3.9/site-packages/aiorpcx/curio.py", line 255, in __aexit__
await self.join()
File "/home/user/.local/lib/python3.9/site-packages/aiorpcx/curio.py", line 213, in join
raise task.exception()
File "/home/user/src/github.com/spesmilo/electrum/electrum/synchronizer.py", line 263, in main
await run_in_thread(self.wallet.synchronize)
File "/home/user/.local/lib/python3.9/site-packages/aiorpcx/curio.py", line 68, in run_in_thread
return await get_event_loop().run_in_executor(None, func, *args)
File "/usr/lib/python3.9/asyncio/base_events.py", line 814, in run_in_executor
executor.submit(func, *args), loop=self)
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 161, in submit
raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
By adding some debug logging to util.py I was able to find that the app was trying to display the following (masked by the other error):
Unable to reference hid.device; maybe hid package is masking hidapi? Try:
pip3 uninstall hid
This hint was correct, and by uninstalling hid the freeze went away. I include below remaining steps I had to take from stock Debian to create a Trezor wallet successfully, in case there's some improvements that could be made.
Next issue was the version of the trezor pulled in by pip3 install -r contrib/requirements/requirements-hw.txt:
W | plugins.trezor.qt.Plugin | Library version for 'trezor' is incompatible.
Installed: 0.13.0, Needed: 0.12.0 <= x < 0.13
This was fixed by editing requirements-hw.txt to set trezor[hidapi]>=0.12.0,<0.13 and reinstalling the older trezor package.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the exception path in electrum/util.py, electrum/interface.py, and electrum/synchronizer.py, then inspect contrib/requirements/requirements-hw.txt and the Trezor plugin mentioned in the report. Reproduce the Debian/Python environment with the conflicting hid and trezor packages; done means the hardware-wallet flow does not freeze and the supported dependency versions are handled clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100