Answer the question
In order to leave comments, you need to log in
Problem with threading and multiprocessing in python, how to use?
There is a ready-made code that launches the command line and performs operations, logging them along the way. I'm trying to set up threading python for faster and more optimized work, but when I specify a parameter, nothing changes. Code attached. Can tell you what parameters to prescribe.
import threading
from multiprocessing.pool import ThreadPool as Pool
import argparse
import requests
import os
parser = argparse.ArgumentParser()
parser.add_argument(
"-t",
"--threads",
help="amount of threads (default: 1000)",
type=int,
default=100,
)
args = parser.parse_args()
lock = threading.Lock()
def main():
with lock:
.......
if __name__ == "__main__":
if not getInternet():
print(bcolors.RED + "No internet connection")
makeDir()
threads = args.threads
pool = Pool(threads)
for _ in range(10):
pool.apply_async(main)
pool.close()
pool.join()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question