Commit 1e8168c6 authored by Mateusz Żebrak's avatar Mateusz Żebrak
Browse files

Override the ThreadPoolExecutor.shutdown method with cancel_futures set by default

This one should help with:

```
Traceback (most recent call last):
  File "/home/mzebrak/1workspace/clive/clive/main.py", line 30, in <module>
    main()
  File "/home/mzebrak/1workspace/clive/clive/main.py", line 22, in main
    run_tui()
  File "/home/mzebrak/1workspace/clive/clive/__private/run_tui.py", line 11, in run_tui
    sys.exit(Clive.app_instance().run())
SystemExit: 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mzebrak/1workspace/clive/clive/main.py", line 29, in <module>
    with thread_pool:
  File "/home/mzebrak/.pyenv/versions/3.10.6/lib/python3.10/concurrent/futures/_base.py", line 649, in __exit__
    self.shutdown(wait=True)
  File "/home/mzebrak/.pyenv/versions/3.10.6/lib/python3.10/concurrent/futures/thread.py", line 235, in shutdown
    t.join()
  File "/home/mzebrak/.pyenv/versions/3.10.6/lib/python3.10/threading.py", line 1096, in join
    self._wait_for_tstate_lock()
  File "/home/mzebrak/.pyenv/versions/3.10.6/lib/python3.10/threading.py", line 1116, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
  File "/home/mzebrak/1workspace/clive/clive/__private/core/raise_exception_helper.py", line 29, in __external_error_handler
    raise exception_to_raise
  File "/home/mzebrak/1workspace/clive/clive/__private/ui/app.py", line 311, in __update_data_from_node
    self.world.commands.update_node_data(
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/commands.py", line 120, in update_node_data
    wrapper = self.__surround_with_exception_handler(
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/commands.py", line 152, in __surround_with_exception_handler
    result: ResultNotAvailable | CommandResultT = exception_handler.execute(command.execute_with_result)
  File "/home/mzebrak/1workspace/clive/clive/__private/core/error_handlers/error_handler_context_manager.py", line 62, in execute
    return self._handle_error(error)
  File "/home/mzebrak/1workspace/clive/clive/__private/core/error_handlers/communication_failure_notificator.py", line 25, in _handle_error
    raise error
  File "/home/mzebrak/1workspace/clive/clive/__private/core/error_handlers/error_handler_context_manager.py", line 59, in execute
    return func()
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/abc/command_with_result.py", line 43, in execute_with_result
    self.execute()
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/abc/command.py", line 32, in execute
    self._execute()
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/update_node_data.py", line 57, in _execute
    api_accounts = self.__harvest_data_from_api()
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/update_node_data.py", line 118, in __harvest_data_from_api
    info.latest_interaction = self.__get_newest_account_interactions(account.name)
  File "/home/mzebrak/1workspace/clive/clive/__private/core/commands/update_node_data.py", line 171, in __get_newest_account_interactions
    self.node.api.account_history_api.get_account_history(
  File "/home/mzebrak/1workspace/clive/clive/__private/core/node/api/api.py", line 41, in wrapper
    return this._node.send(request, expect_type=Response).result
  File "/home/mzebrak/1workspace/clive/clive/__private/core/node/node.py", line 39, in send
    response = Communication.request(str(self.address), data=request.json(by_alias=True))
  File "/home/mzebrak/1workspace/clive/clive/__private/core/communication.py", line 68, in request
    asyncio_run(
  File "/home/mzebrak/1workspace/clive/clive/__private/core/_async.py", line 18, in asyncio_run
    return thread_pool.submit(asyncio.run, coroutine).result()
  File "/home/mzebrak/.pyenv/versions/3.10.6/lib/python3.10/concurrent/futures/thread.py", line 167, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
sys:1: RuntimeWarning: coroutine 'Communication.__request' was never awaited
```
parent d72b1ee5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment