multithreading - How to run two python scripts in parallel on Windows -


I currently have two dragon scripts, one is to write the data in the file and the second is to read from the data one Just file in the timeline and plotting I would like to create a third script that can automatically run these two scripts at the same time (in fact, a little ahead of each other because the need to create a file for the second script Is it For Hne).

Here is my code: import serial import cis import import line import threading import scipy.io import numpy as mpl_toolkits.mplot3d import import * import matplotlib.pyplot plt import nppy as np form Import import time from matplotlib import into import timer as import timing import matplotlib.animation AngleText = Open ("data2.txt", "w") # Open file A to write data A = 1B = 1C = 1 < / Code>

for range in range (020):

  count = 0 sleep (0.5) angle text. AngleText.writelines (str (c) + '\ n') count = count +1 a = a + 1b (str (a) + ',') AngleText.writelines (str (b) + ',') = B + 2 c = c + 3 AngleText.flush ()  

and plotting script:

  to mpl_toolkits.mplot3d import * import matplotlib.pyplot As imported plt import m appletb. Animation import time import metpllib import threading thread imported as NP fig = PLT.figure () ax = fig.add_subplot (111, projection = '3d') def ammate (i ): Puladata = Open ('Data2 .txt', 'r'). For every lin in the data: if the lane (each line)> 1: x, y, z = everyLine.split (' , ') Xar.append (float (x) yar.append (float (y)) zar.append (float (z)) tx = xar.pop (0) floatx = float (tx) = yar.pop ( 0) Floty = Float (TE) tees = porport (0) floats = float (tees) x1 = [164, 94, 0, -100.5] x2 = [164, 94, 0, -100.5] y1 = [-72.5 , -103.5, -103.5, -134.5] y2 = [72.5, 103.5, 103.5, 134.5] z1 = [112, 60, 3, 3] z2 = [112, 60, 3, 3] ax.plot (x1, y1) Plt.hold (true) ax.plot (x2, y2, z2, color = 'r') plt.hold (true) ax scatter (float x, flotty, floats) plt.hold (False) ani = animationAx.set_ylabel ('y label') ax.set_zlabel ('z label') plt.show ()  

Any advice would be appreciated!

My current solution is:

  import os from output = p.com muqt () print output [0] sleep (0.5) import from time * time import sleep Import from * PPN ([R'ttingings '], Shell = True, staden = pipe, standout = PIPE) #run child script 2p = popen ([r'realPlot2.py'], shell = True, stdin = PIPE, Stdout = PIPE) output = p.communicate () print output [0]  

By running the above code, it will not be able to show the graph until it has finished writing.

Use a multiprocessing class You can start a new process to write in the file, then the main To end the work, call p.join () to finish the first process, then start another process. Check here:


Comments

Popular posts from this blog

eclipse plugin - Run java code error: Workspace is closed -

ios - How do I use CFArrayRef in Swift? -

scala - Play Framework - how to bind form to a session field -