janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
13.13k stars 1.4k forks source link

Unix: Calibre Conversion Hangs when Embed Metadata Enabled #3143

Closed ConstrictM closed 6 days ago

ConstrictM commented 2 months ago

Describe the bug/problem Attempting to convert a book with embed metadata enabled causes the Calibre ebook-converter to lock due to the calibredb metadata extraction process being locked.

This appears to be due to the p.wait() (convert.py, line 272) not being released until the stdout buffer has been cleared.

From convert.py

269 opf_command = [calibredb_binarypath, 'show_metadata', '--as-opf', str(self.book_id),
270               '--with-library', library_path]
271 p = process_open(opf_command, quotes, my_env)
272 p.wait()
273 check = p.returncode
274 calibre_traceback = p.stderr.readlines()
275 if check == 0:
276     path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(uuid4()) + ".opf")
277     with open(path_tmp_opf, 'w') as fd:
278         copyfileobj(p.stdout, fd)

To Reproduce

Steps to reproduce the behavior:

  1. Go to any book (that is type EPUB)
  2. Click on 'Edit Metadata'
  3. Set Convert from: EPUB
  4. Set Convert to: AZW3
  5. Go to Tasks to see that conversion is stuck
  6. In processes calibredb process is stuck

Expected behavior

The conversion task does not get stuck an completes as expected.

Environment (please complete the following information):

ConstrictM commented 6 days ago

Fixed by changes made in 4fa7520