Skip to main content
Solved

Python Exception <TypeError>: bufsize must be an integer


rejith3119
Participant
Forum|alt.badge.img

Hi,

I was trying to use below python code in FME. But it is throwing an error i.e. '<TypeError>: bufsize must be an integer'. Can anyone help me on this to get it resolved? I will provide the complete script on request if required.

Thanks in advance

#Code used in python caller
arg1 = ['pg_dump''-t''schema1_table1''server1_conn','|','psql''local_conn']
proc = subprocess.Popen(arg1,cwd=directory, shell=True,stdin=PIPE)
 
#where 
#server1_conn = "host=<server_host> port=<server_port> dbname=<server_db> user=<server_user> password=<server_pwd>"
#directory = C:\Program Files\PostgreSQL\14\bin

 

Best answer by rejith3119

david_r wrote:

I'm suspecting you cannot pipe ("|") the output the way you're doing, you probably need to specify the stdout parameter to subprocess.Popen() instead, and take it from there.

Hi @david_r​ ,

There is no issue with the pipe("|") character. Actually the error was with the variable declaration and some syntax in the argument value e.g. 'server1_conn'. After correcting it the python caller is working fine. I have used this 'subprocess.popen' method to get control on the child process like below. Your comment helped me to explore more on subprocess.Popen() documentation. Thank you for the support

proc = subprocess.Popen(...)
try:
    outs, errs = proc.communicate(timeout=15)
except TimeoutExpired:
    proc.kill()
    outs, errs = proc.communicate()

 

View original
Did this help you find an answer to your question?

3 replies

david_r
Celebrity
  • August 23, 2022

I'm suspecting you cannot pipe ("|") the output the way you're doing, you probably need to specify the stdout parameter to subprocess.Popen() instead, and take it from there.


rejith3119
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • Best Answer
  • August 24, 2022
david_r wrote:

I'm suspecting you cannot pipe ("|") the output the way you're doing, you probably need to specify the stdout parameter to subprocess.Popen() instead, and take it from there.

Hi @david_r​ ,

There is no issue with the pipe("|") character. Actually the error was with the variable declaration and some syntax in the argument value e.g. 'server1_conn'. After correcting it the python caller is working fine. I have used this 'subprocess.popen' method to get control on the child process like below. Your comment helped me to explore more on subprocess.Popen() documentation. Thank you for the support

proc = subprocess.Popen(...)
try:
    outs, errs = proc.communicate(timeout=15)
except TimeoutExpired:
    proc.kill()
    outs, errs = proc.communicate()

 


david_r
Celebrity
  • August 29, 2022
rejith3119 wrote:

Hi @david_r​ ,

There is no issue with the pipe("|") character. Actually the error was with the variable declaration and some syntax in the argument value e.g. 'server1_conn'. After correcting it the python caller is working fine. I have used this 'subprocess.popen' method to get control on the child process like below. Your comment helped me to explore more on subprocess.Popen() documentation. Thank you for the support

proc = subprocess.Popen(...)
try:
    outs, errs = proc.communicate(timeout=15)
except TimeoutExpired:
    proc.kill()
    outs, errs = proc.communicate()

 

That is great to hear, thank you for sharing your findings!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings