0

I use Python 3.6 and start a process in my script (VTK Visualization). Until I close the visualization window the command line is blocked which I want to change. I read something about multiprocessing and threading, but I'm not sure which is the right approach.

This is what I want to achieve and my ideas:

  • start two processes (visualization window and a loop for inputs)
  • with exec(input) the inputs are written into my script
  • after that the visualization window is updated

I am thankful for any advice on which method could be suitable for my intend!

Edit: I tried threading and started both threads, but still the command line was blocked until I closed the window and just opened up again after typing in an input.. Is there anyone who achieved something similar before?

  • Threading probably. Multiprocessing would create separate processes making communication between the two harder than threading. – Xantium Jul 12 '18 at 09:13
  • [You'll have to use multiprocessing through threads](https://docs.python.org/2/library/threading.html) – Hearner Jul 12 '18 at 09:13

1 Answers1

0
from multiprocessing
p = multiprocessing.Pool(1)
p.map(VTZ,args)
p.close()

this will open the vtz visualizations on 1 seperate thread. if you are passing information between threads, you must have Pipe() arguments. which is a much more complicated.

another way. import os import threading

t2 = threading.Thread(os.sys('python programName')
t2.start()

os.sys('python programName') this calls the command prompt and enters args for you. by doing this it's virtually impossible to pass information back and fourth between windows.

Michael Smith
  • 77
  • 1
  • 10