Ad

IronPython Error On Process.WaitforExit() Arguments

- 1 answer

I am trying to run an external macro using IronPython. sometimes I am bugged by the error :

TypeError: WaitForExit() takes at least 1 argument (0 given)

what argument should I insert?

here says nothing is needed

I do :

from System.Diagnostics import Process
Process.Start(r"C:\python.exe", 'python.py')
Process.WaitForExit()
Ad

Answer

WaitForExit is an instance method that needs to know which process you are waiting on. The code needs to be more along the lines of

from System.Diagnostics import Process
process = Process.Start(r"C:\python.exe", 'python.py')
process.WaitForExit()

Assuming a default IronPython installation the following sample shows that the main script actually waits in a more self-contained way (no dependency on installed CPython):

from System.Diagnostics import Process
ipy = r"C:\Program Files\IronPython 2.7\ipy.exe"
process = Process.Start(ipy, '-c "import time; time.sleep(10)"')
process.WaitForExit()
Ad
source: stackoverflow.com
Ad