簡體   English   中英

Beeline 不能在 python 中使用 subprocess.run,永遠卡住

[英]Beeline not working with subprocess.run in python, getting stuck forever

我正在嘗試從 Python 腳本通過直線連接並運行 hql 腳本。 我無法使用 subprocess.run 或 subprocess.popen 運行。 我可以直接在命令提示符下運行它

beeline_connect=str('"jdbc:hive2://192.168.0.100:10000/serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;transportMode=http;httpPath=cliservice;principal=hive/system1.example.co.in@EXAMPLE.CO.IN"')
        
#passing params as a list
 
         param_list= ['beeline -u' + beeline_connection,'-hivevar', 'VAR1=val1', '-hivevar', 'VAR2=val2', '-hivevar', 'VAR3=val3', '-hivevar', 'VAR4=val4', '-hivevar', 'VAR5=val5', '-f', '/my/path/filename.hql']

command = subprocess.run(param_list, check=True, stdout=subprocess.PIPE)
                output = command.stdout
                status = str(output.decode('utf-8'))
                print(
                    '****Its failed****, return code {1} with return count {2} :'.format(command.returncode, status))

                if command.returncode > 0:
                    print('Job failed. Raising exception')
                    raise Exception('Job ' + job_name + ' failed')

            else:
               ## do something else###

#####i 也嘗試過 shell=True 和 False,並刪除 stdout

它永遠卡住了,我聯系直線命令的方式有什么問題嗎? 我嘗試了以下連接的多種組合,但沒有運氣。 任何幫助將是非常可觀的。 謝謝

param_list =['beeline', '-u' + beeline_connection...]
param_list =['beeline', '-u', beeline_connection....]
 

如下更改代碼行對我有用

param_list= ['beeline', '-u',beeline_connection,'-hivevar', 'VAR1=val1', '-hivevar', 'VAR2=val2', '-hivevar', 'VAR3=val3', '-hivevar', 'VAR4=val4', '-hivevar', 'VAR5=val5', '-f', '/my/path/filename.hql']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM