Mar-04-2017, 02:13 PM
This post is getting dark.
I have a small gui with tkinter and python 2.7, where I need to execute shutil.copy2(), which can take some time. Obviously, I don't want to block the gui, so I figured I could os.fork() a child process:
I've also tried just creating a new toplevel window for the child, but the copy2() still blocks both the parent and child windows, so that doesn't work either.
How can I kill the child, or am I going about this in the wrong manor?
I have a small gui with tkinter and python 2.7, where I need to execute shutil.copy2(), which can take some time. Obviously, I don't want to block the gui, so I figured I could os.fork() a child process:
pid = os.fork() if pid == 0: shutil.copy2() quit() # Kill the child print "Parent continues..."That's the general idea. However, what is happening is that when the quit() executes, both child and parent are terminated. Since this is a graphical interface, the mainloop, I expect, would keep the child running if I don't terminate it in some fashion.
I've also tried just creating a new toplevel window for the child, but the copy2() still blocks both the parent and child windows, so that doesn't work either.
How can I kill the child, or am I going about this in the wrong manor?