Beispiel #1
0
 def test_bar(self):
     stime = timer()
     # On MS Windows, do not run this in a shell.  If so, MS Windows has difficulty
     # killing the process after the timelimit
     print("Subprocess python process")
     sys.stdout.flush()
     foo = SubprocessMngr("python -q -c \"while True: pass\"", shell=not subprocess.mswindows)
     foo.wait(5)
     print("Ran for %f seconds" % (timer()-stime))
Beispiel #2
0
 def test_foo(self):
     if not subprocess.mswindows:
         foo = SubprocessMngr("ls *py > /tmp/.pyutilib", stdout=subprocess.PIPE, shell=True)
         foo.wait()
         print("")
         if os.path.exists("/tmp/.pyutilib"):
             os.remove("/tmp/.pyutilib")
     else:
         foo = SubprocessMngr("cmd /C \"dir\" > C:/tmp", shell=True)
         foo.wait()
         print("")
 def test_foo(self):
     if not _mswindows:
         foo = SubprocessMngr("ls *py > /tmp/.pyutilib",
                              stdout=subprocess.PIPE,
                              shell=True)
         foo.wait()
         print("")
         if os.path.exists("/tmp/.pyutilib"):
             os.remove("/tmp/.pyutilib")
     else:
         foo = SubprocessMngr("cmd /C \"dir\" > C:/tmp", shell=True)
         foo.wait()
         print("")
Beispiel #4
0
 def test_timeout(self):
     targetTime = 2
     stime = timer()
     # On MS Windows, do not run this in a shell.  If so, MS Windows has difficulty
     # killing the process after the timelimit
     print("Subprocess python process")
     sys.stdout.flush()
     if ' ' in sys.executable:
         foo = SubprocessMngr("'" + sys.executable + "' -q -c \"while True: pass\"", shell=not subprocess.mswindows)
     else:
         foo = SubprocessMngr(sys.executable + " -q -c \"while True: pass\"", shell=not subprocess.mswindows)
     foo.wait(targetTime)
     runTime = timer()-stime
     print("Ran for %f seconds" % (runTime,))
     # timeout should be accurate to 1/10 second
     self.assertTrue( runTime <= targetTime + 0.1 )
 def test_timeout(self):
     targetTime = 2
     stime = timer()
     # On MS Windows, do not run this in a shell.  If so, MS Windows has difficulty
     # killing the process after the timelimit
     print("Subprocess python process")
     sys.stdout.flush()
     if ' ' in sys.executable:
         foo = SubprocessMngr("'" + sys.executable +
                              "' -q -c \"while True: pass\"",
                              shell=not _mswindows)
     else:
         foo = SubprocessMngr(sys.executable +
                              " -q -c \"while True: pass\"",
                              shell=not _mswindows)
     foo.wait(targetTime)
     runTime = timer() - stime
     print("Ran for %f seconds" % (runTime, ))
     # timeout should be accurate to 1/10 second
     self.assertTrue(runTime <= targetTime + 0.1)