maomao2028
Members-
Content Count
7 -
Joined
-
Last visited
Everything posted by maomao2028
-
How to run a multi-process script as following by P4D: from multiprocessing import Pool, TimeoutError import time import os def f(x): return x*x if __name__ == '__main__': # start 4 worker processes with Pool(processes=4) as pool: # print "[0, 1, 4,..., 81]" print(pool.map(f, range(10))) # print same numbers in arbitrary order for i in pool.imap_unordered(f, range(10)): print(i) # evaluate "f(20)" asynchronously res = pool.apply_async(f, (20,)) # runs in *only* one process print(res.get(timeout=1)) # prints "400" # evaluate "os.getpid()" asynchronously res = pool.apply_async(os.getpid, ()) # runs in *only* one process print(res.get(timeout=1)) # prints the PID of that process # launching multiple evaluations asynchronously *may* use more processes multiple_results = [pool.apply_async(os.getpid, ()) for i in range(4)] print([res.get(timeout=1) for res in multiple_results]) # make a single worker sleep for 10 secs res = pool.apply_async(time.sleep, (10,)) try: print(res.get(timeout=1)) except TimeoutError: print("We lacked patience and got a multiprocessing.TimeoutError") print("For the moment, the pool remains available for more work") # exiting the 'with'-block has stopped the pool print("Now the pool is closed and no longer available")
-
thanks very much.
-
Great, it works. Can the console window be hidden when the program is running?
-
Thanks for your help, now the thread is running fine
-
It seems ThreadPythonExec does not work. and memory leak occurs procedure TForm1.Button2Click(Sender: TObject); begin ThreadPythonExec( procedure begin GetPythonEngine.Execstring('print(10)'); end); end;
-
In delphi, with the help of p4d's mainmodule.xxx(v), the python function is called, where the v input is the bytes type, how to convert Tbytes to bytes type in Delphi
-
[help] how to convert delphi TBytes to python Bytes
maomao2028 replied to maomao2028's topic in Python4Delphi
Thanks, It does works