python 2.7 - How should I have one process blocked until another process writes a line to a file? -


I have a process (AGCP) that receives the data and writes them a file and sends data to the other process.

When agoxyip is started, then it should produce some output immediately. I want to block the main process unless the first row of output is displayed by the exgp in the file.

I'm checking that the file is written in the first row while comparing the status of the file, but they are always the same. So I got stuck in the loop. Why does this happen

  rvListen_AGX = "tibrvlisten -service" + agxService + "-network" + agxNetwork + "-daemon" + domain agxf = open (self.AGX_logFileName, 'mou') agxstat = os.stat (self.AGX_logFileName) agxp = subprocess.Popen (rvListen_AGX.split (), stdout = agxf, bufsize = 0) while os.stat (self.AGX_logFileName) == agxstat: Print os.stat agxstat print (self.AGX_logFileName) stxf .flush () sleep (0.1)  

to wait for hair to process your Stdaut for Writes a line in and save the child's standout in a file:

  import shell, threading imported via subprocess import Pope from known, Piaipii Thread DP copy_and_close (source, destination) with the source, destination: shutil.copyfileobj (source, destination) agx_cmd = ( "tibrvlisten -service {agxService}-network {agxNetwork}" "-demon {domain} Formats (** Wars ()). Split () agx_process = popen (agx_cmd, stdout = pipe, bufsize = 1) agx_file = open (self.AGX_logFileName, 'WB') agx_file.write (agx_process.stdout.readline ()) to a line #BLOCK Thread (target = Copy_and_close, arg = [agx_process.stdout, agx_file]) is read. Start () # There are other things .. rc = agx_process.wait ()  

If you do other things while agx_process is running you say Can copy_and_close () instead of in the main thread.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -