I just switched to python3 as a result of its parallel futures module. I was wondering if I can detect errors. I want to use parallel futures for a parallel program, if there are more efficient modules, please let me know.
I do not like multiprocessing, because it is too complicated and not much documentation. It would be great, however, if someone could write Hello World without classes only functions that use multiprocessing for parallel computation, so this is easy to understand.
Here is a simple script:
from concurrent.futures import ThreadPoolExecutor def pri(): print("Hello World!!!") def start(): try: while True: pri() except KeyBoardInterrupt: print("YOU PRESSED CTRL+C") with ThreadPoolExecutor(max_workers=3) as exe: exe.submit(start)
The above code was just a demonstration of how CTRL + C would not work to print an application.
I want to be able to call a function, there is an error. This error detection must be from the function itself.
Another example
import socket from concurrent.futures import ThreadPoolExecutor s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) def con(): try: s.connect((x,y)) main() except: socket.gaierror err() def err(): time.sleep(1) con() def main(): s.send("[+] Hello") with ThreadPoolExecutor as exe: exe.submit(con)
source share