BUG #14583: plpythonu : subprocess not working in function

paulo.nuno.leite@gmail.com

From: paulo.nuno.leite@gmail.com
To: pgsql-bugs@postgresql.org
Date: 2017-03-08T17:51:19Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      14583
Logged by:          Paulo B
Email address:      paulo.nuno.leite@gmail.com
PostgreSQL version: 9.5.6
Operating system:   Windows
Description:        

I have the following function that runs a command:


CREATE OR REPLACE FUNCTION public.classify_test()
  RETURNS void AS
$BODY$
import os
from subprocess import Popen, PIPE
import subprocess
import os
from subprocess import Popen, PIPE

echo=Popen(('echo', '123'), shell=True)

p = subprocess.Popen(['python.exe', '-u','test.py'], stdin = echo.stdout,
universal_newlines = True, shell = True)
	
$BODY$
  LANGUAGE plpythonu VOLATILE
  COST 100;
ALTER FUNCTION public.classify_test()
  OWNER TO postgres;

if I run this fuction as select classify_test() it will not run the python
script. However, if I run it in the command line it will work. It works as
well in SublimeText2 IDE. I have been trying to find what the bug or problem
is, but had no success. I am using python2.7, I have psycopg2 installed. 

Why doesn't  postgresql  execute the python script?