MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test

Function test

pydevd_attach_to_process/add_code_to_python_process.py:559–585  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

557
558
559def test():
560 print("Running with: %s" % (sys.executable,))
561 code = """
562import os, time, sys
563print(os.getpid())
564#from threading import Thread
565#Thread(target=str).start()
566if __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
588def main(args):

Callers 1

Calls 2

run_python_codeFunction · 0.85
killMethod · 0.45

Tested by

no test coverage detected