()
| 557 | |
| 558 | |
| 559 | def test(): |
| 560 | print("Running with: %s" % (sys.executable,)) |
| 561 | code = """ |
| 562 | import os, time, sys |
| 563 | print(os.getpid()) |
| 564 | #from threading import Thread |
| 565 | #Thread(target=str).start() |
| 566 | if __name__ == '__main__': |
| 567 | while True: |
| 568 | time.sleep(.5) |
| 569 | sys.stdout.write('.\\n') |
| 570 | sys.stdout.flush() |
| 571 | """ |
| 572 | |
| 573 | p = subprocess.Popen([sys.executable, "-u", "-c", code]) |
| 574 | try: |
| 575 | code = 'print("It worked!")\n' |
| 576 | |
| 577 | # Real code will be something as: |
| 578 | # code = '''import sys;sys.path.append(r'X:\winappdbg-code\examples'); import imported;''' |
| 579 | run_python_code(p.pid, python_code=code) |
| 580 | print("\nRun a 2nd time...\n") |
| 581 | run_python_code(p.pid, python_code=code) |
| 582 | |
| 583 | time.sleep(3) |
| 584 | finally: |
| 585 | p.kill() |
| 586 | |
| 587 | |
| 588 | def main(args): |
no test coverage detected