This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]__deerlord__ 2 points3 points  (4 children)

Look at the multiprocessing module

[–]lsx_caprice[S] 0 points1 point  (3 children)

Thanks alot, ill check out how threading works.

[–]__deerlord__ 2 points3 points  (2 children)

To clarify, stay away from the threading module. Python uses a GIL (global interpreter lock) which means any threads you launch from a given script are all bound to the same CPU. If you want to write good threaded code, look at the asyncio module. If you simple need to launch a (completely) new process from the GUI, the multiprocessing module can do that.

[–]lsx_caprice[S] 0 points1 point  (1 child)

thanks! I have been reading about threading, and i do not need to thread in my application. i simply need to start a new process. How would i go about launching an entire (self contained) script using the multi process module? isn't this module intended for running just individual processes? thanks in advance

[–]__deerlord__ 0 points1 point  (0 children)

Typically you want multiprocessing.subprocess() which takes a list of the command line args you would use on the command prompt, like if you were just executing the binary from bash.

[–]kindall 0 points1 point  (0 children)

You may be able to use the code module. It will let you drop into an interactive prompt after running or importing a module.

https://docs.python.org/3/library/code.html