1

I am trying to run and interact with a vendor specific old version of Python (SunGard Arena Python) from a main Python program through Popen, as I need access to a database through the vendor version of Python.

I can run the vendor Python through the shell though I get

'import site' failed; use -v for traceback.

Now when I try to run it through Popen, if I do the standard:

proc = Popen('U:arena_python.exe',bufsize=-1,stdin=PIPE, stdout=PIPE, stderr=STDOUT)

it doesn't work at all and when I do proc.communicate() I get:

('An exception has occurred -- see the traceback log in "acm_.log".\nCreated a minidump in ".\\arena_python-20160216-092027-942.dmp".\n\'import site\' failed; use -v for traceback\n', None)

The log mentions an access violation in C:\windows\SysWOW64\ntdll.dll. Strangely, if I run the above and include a script as a command line argument, the script runs fine before the process crashes again. Playing around, it seems to work better if I run it with the close_fds=True:

Popen('U:arena_python.exe',bufsize=-1,close_fds=True)

But then I don't know how to interact with the process - the documentation says that on Windows you can't use close_fds=True and redirect input/output.

Any idea what is going on? How can I interact with the process? Thank you,

alex314159
  • 3,159
  • 2
  • 20
  • 28
  • It looks like that sunguard python you're invoking is heavily bugged and would probably be better fixed by its support team. If you really want to try, you could play with the [`STARTUPINFO`](https://docs.python.org/2/library/subprocess.html#subprocess.STARTUPINFO), passing explicit file handles to the underlying `CreateProcess`. If I understand it correctly, those should work even with `close_fds=True`. – spectras Feb 16 '16 at 10:12
  • Thanks @spectras. On further investigation, it looks like what's really crashing the process is the stdin - if I don't use any stdin it works, but it defeats my purpose. I wonder if I can get the subprocess to listen to input commands from another means? – alex314159 Feb 19 '16 at 11:07
  • If you are writing the code on both sides, you could either drop the commands in a temporary file if you don't need realtime control, or you could use a socket. Or a named pipe maybe. Those will all feel a bit hackish, but the starting point is overcoming a bugged program so… – spectras Feb 19 '16 at 16:17

1 Answers1

1

I know it's an old post, but for the record, here's my solution:

I had this problem too. I have found a tricky workaround for it, published in the following Q&A: Howto: workaround of close_fds=True and redirect stdout/stderr on windows

Have a good day.

Cukic0d
  • 5,111
  • 2
  • 19
  • 48