Solved

Python Exception <TypeError>: bufsize must be an integer

  • 23 August 2022
  • 3 replies
  • 145 views

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

 

icon

Best answer by rejith3119 24 August 2022, 16:17

View original

3 replies

Userlevel 4

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.

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

 

Userlevel 4

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!

Reply