Skip to main content
Solved

Python Exception <TypeError>: bufsize must be an integer

  • August 23, 2022
  • 3 replies
  • 631 views

rejith3119
Contributor
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

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()

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • Best Answer
  • August 24, 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.

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

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!