小编Moi*_*man的帖子

hcitool lescan子进程python不产生输出

我的子流程代码有问题.该subprocess.Popen()工作正常,但是当我试图通过阅读它的输出stdout.read()是没有价值的阅读.

**import os
import signal
import subprocess
import threading
import sys
import commands

print commands.getoutput("hcitool dev")
print 'down'
commands.getoutput('hciconfig hci1 down')
print 'up'
commands.getoutput('hciconfig hci1 up')
commands.getoutput('killall hcitool')
stop = False
ping = subprocess.call('hcitool lescan', shell = False,
stdout=subprocess.PIPE,executable='/bin/bash')
for i in ping.stdout:
    print i

def kill():
    global stop
    stop = True
    os.kill(ping.pid, signal.SIGTERM)

threading.Timer(5, kill).start()

#while not stop:
#   print 'now in while not loop'
#   sys.stdout.write(ping.stdout.read(1))

print 'trying to print stdout'
out, err = …
Run Code Online (Sandbox Code Playgroud)

python subprocess

0
推荐指数
1
解决办法
3919
查看次数

标签 统计

python ×1

subprocess ×1