Skip to content

Commit

Permalink
🧵 Add Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Feb 26, 2024
1 parent 39ffafd commit 60536c5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/modules/create_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from .link_parse import Link, LinkFile

from concurrent.futures import ThreadPoolExecutor


class CreatePDF:
"""Merge the images of books into PDF files
Expand Down Expand Up @@ -51,10 +53,13 @@ def merge_jpg_to_pdf_book_link(book_directory: str, link: Link) -> None:
directory (str): The directory containing the subdirectories.
link (Link): The book's Link
"""
for link_page in link.files:
CreatePDF.merge_jpg_to_pdf_page_link_or_preview_link(
os.path.join(book_directory, link_page.name), link_page
)
with ThreadPoolExecutor() as executor:
for link_page in link.files:
executor.submit(
CreatePDF.merge_jpg_to_pdf_page_link_or_preview_link,
os.path.join(book_directory, link_page.name),
link_page,
)

@staticmethod
def create_pdf(dowload_directory: str, links: list[Link]) -> None:
Expand Down

0 comments on commit 60536c5

Please sign in to comment.