Skip to content

Commit

Permalink
Upgrade to new multiprocessing API.
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Jan 3, 2021
1 parent e2d68ac commit 85d68a3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .travis/complementary/api_file_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DirectoryStructureRestoration,
)
from PyFunceble.cli.threads.file_producer import FileProducerThread
from PyFunceble.cli.processes.producer import ProducerProcessesManager

# We initiate the coloration.
colorama.init(autoreset=True)
Expand Down Expand Up @@ -51,8 +52,8 @@
).restore_from_backup()

# We start the producer thread.
file_producer_thread = FileProducerThread()
file_producer_thread.start()
producer_process_manager = ProducerProcessesManager()
producer_process_manager.start()

# We start and configure our availability checker.
avail_checker = DomainAvailabilityChecker(use_whois_lookup=False)
Expand All @@ -79,15 +80,15 @@

# We order the generation of the status file by putting our information
# to the producer queue.
file_producer_thread.add_to_the_queue((communication_dataset, test_result))
producer_process_manager.add_to_input_queue((communication_dataset, test_result))

# We are now done, it's time to send the stop signal.
# The stop signal will inform thhe producer thread that it needs to stop
# listening to new order (from the time it reads the stop signal).
file_producer_thread.send_stop_signal()
producer_process_manager.send_stop_signal()

# Now we wait until it's done.
file_producer_thread.wait()
producer_process_manager.wait()

# From here all files were generated we can do whatever we want with them.

Expand Down

0 comments on commit 85d68a3

Please sign in to comment.