小编Dre*_*man的帖子

为什么subprocess.Popen不等待子进程终止?

我遇到了Python的subprocess.Popen方法的问题.

这是一个演示问题的测试脚本.它正在Linux机器上运行.

#!/usr/bin/env python
import subprocess
import time

def run(cmd):
  p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
  return p

### START MAIN
# copy some rows from a source table to a destination table
# note that the destination table is empty when this script is run
cmd = 'mysql -u ve --skip-column-names --batch --execute="insert into destination (select * from source limit 100000)" test'
run(cmd)

# check to see how many rows exist in the destination table
cmd = 'mysql -u ve …
Run Code Online (Sandbox Code Playgroud)

python mysql

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

mysql ×1

python ×1