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

Crash on Python 3.7 related to treading / concurrent.future #32

Closed
flozz opened this issue Oct 14, 2022 · 2 comments
Closed

Crash on Python 3.7 related to treading / concurrent.future #32

flozz opened this issue Oct 14, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@flozz
Copy link
Owner

flozz commented Oct 14, 2022

Error encountered in Python 3.7.14. No issue in 3.10.7 though. Manage different Python versions using pyenv.

Steps to reproduce:

git clone https://github.com/flozz/yoga-image-optimizer.git
cd yoga-image-optimizer
sudo pip3 install .

Stacktrace:

$ yoga-image-optimizer
...
Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/threading.py", line 926, in _bootstrap_inner                                                                                     self.run()
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs)                                               File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/concurrent/futures/process.py", line 375, in _queue_management_worker
    thread_wakeup.clear()                                                                   File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/concurrent/futures/process.py", line 93, in clear
    while self._reader.poll():
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/multiprocessing/connection.py", line 255, in poll
    self._check_closed()
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/multiprocessing/connection.py", line 136, in _check_closed
    raise OSError("handle is closed")
OSError: handle is closed

Traceback (most recent call last):
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/site-packages/yoga_image_optimizer/main_window.py", line 385, in _on_main_window_destroyed
    app.quit()
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/site-packages/yoga_image_optimizer/application.py", line 142, in quit
    self._thumbnailer.cancel_all()
  File "/home/foobar/.pyenv/versions/3.7.14/lib/python3.7/site-packages/yoga_image_optimizer/thumbnailer.py", line 156, in cancel_all
    self._executor.shutdown(wait=False, cancel_futures=True)
TypeError: shutdown() got an unexpected keyword argument 'cancel_futures'

Originally posted by @kianmeng in #30 (comment)

@flozz flozz added the bug Something isn't working label Oct 14, 2022
@flozz flozz closed this as completed in b894c81 Oct 14, 2022
@flozz
Copy link
Owner Author

flozz commented Oct 14, 2022

The first error is caused by a bug in the concurrent.futures.ProcessPoolExecutor implementation of Python 3.7 and 3.8 (fixed in 3.9):

https://bugs.python.org/issue36281

I can workaround by killing process before requesting the shutdown of the executor, and by adding wait=True as parameter.


The second error is my fault: the cancel_futures parameter does not exist before Python 3.9, so we should cancel futures one by one manually on older Python version.


Both errors are fixed on master :)

@kianmeng
Copy link
Contributor

kianmeng commented Oct 15, 2022

@flozz Thanks for the explanation and fix. I've tried and it worked without issues, 🥳 !

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants