Relative Content

Tag Archive for pythonmultithreading

threading in console error but not run error

import threading import time class ClockThread(threading.Thread): def __init__(self, interval): threading.Thread.__init__(self) self.daemon = True self.interval = interval def run(self): while True: print(“The time is %s” % time.ctime()) time.sleep(self.interval) t = ClockThread(1) t.start() time.sleep(5) this is my code.i use is ok,but when i use in console if find this code can’t stop like this The time is […]

Python, running concurrent.futures.ThreadPoolExecutor inside another concurrent.futures.ThreadPoolExecutor

I am running subdomain enumeration using different tools where I will iterate a list of domains over a list of tools. To speed up the process, I implemented multi threading using concurrent.futures.ThreadPoolExecutor. In my scenario, I will have two ThreadPoolExecutor, first one is when I iterate through (lets say) 10000 domains, the second one will be when I iterate and run the 7 different command line tools(using subprocess to run the command) on one specific domain.

How to control sequence of execution of customtkinter program

The attached customtkinter program jumps to the end print statements before any selection from the comboboxes. How can I control the program execution so the user selects the baudrate and port from the comboboxes and then the tk.IntVar and tk.String.Var are updated to be used in another section of the program that will connect to a serial port with the baudrate and port tk.variables
also how do I get the 4 space indent on the code below so others won’t need to correct it thanks

How to make my dictionary thread safe in python?

Python beginner. I have a class as follows, which maintains simple dictionary for historical records. It needs to support insertion of records and lookup, i.e. given ID and year, returns all records older than given year.

How to dynamically create threads depending upon the CPU usage to execute the script faster

I am making a program in python which take in a large list and use each item of the list to perform a task.
One way to make this efficient is to split the list in multiple parts and then use multi threading on those sub-lists to reduce the time of execution.
My question is how we can dynamically create threads (sub processes) depending upon how much CPU is being used (other apps might also be running in the background). For example if there are no background processes running, I want my script to dynamically create maximum available sub processes (threads) and reduce the execution time to a great extent, and if there are other task running in the background, it should create fewer number of sub processes.