-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start Jack #31
Labels
Milestone
Comments
Subprocess Asyncio https://docs.python.org/3/library/asyncio-subprocess.html import asyncio
import signal
from subprocess import PIPE
@asyncio.coroutine
def ls(loop):
arguments = ['ls', '-la']
proc = yield from asyncio.create_subprocess_exec(*arguments, stdout=PIPE)
while True:
line = yield from proc.stdout.readline()
if not line:
break
print("ls>>", line.decode('ascii').rstrip())
print('CLOSED')
try:
proc.send_signal(signal.SIGINT)
except ProcessLookupError:
pass
@asyncio.coroutine
def call_process(loop, arguments, function):
proc = yield from asyncio.create_subprocess_exec(*arguments, stdout=PIPE)
while True:
line = yield from proc.stdout.readline()
if not line:
break
function(line.decode('ascii').rstrip())
try:
proc.send_signal(signal.SIGINT)
except ProcessLookupError:
pass
def inspect(line):
print('> ', line)
loop = asyncio.get_event_loop()
# Blocking call which returns when the hello_world() coroutine is done
loop.run_until_complete(call_process(loop, ['jackd', '-d', 'alsa'], inspect))
#loop.close()
try:
loop.run_forever()
finally:
loop.close() |
import subprocess
'''
def execute(cmd):
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
for stdout_line in popen.stdout:
print(stdout_line)
yield stdout_line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
'''
# Example
#command = 'jackd -R -P70 -t2000 -dalsa -dhw:0 -p256 -n3 -r44100 -s'.split()
command = 'mod-host'.split()
#for path in execute(command):
# print(path, end="")
'''
with subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as p:
try:
for line in p.stdout:
print('AAA', line, end='') # process line here
except:
print("cadê")
p.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
'''
'''
with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
for line in p.stderr:
print('Error:', line)
'''
'''
with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
for output, error in p.communicate():
print('output:', output)
print('error:', error)
'''
with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
# for line in p.stderr:
for line in p.stdout:
print('Error:', line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful for real mod-devices test
No library was found to start or manage a jack daemon.
I believe a new library should be implemented for this.
--
Async io - https://medium.freecodecamp.com/a-guide-to-asynchronous-programming-in-python-with-asyncio-232e2afa44f6
The text was updated successfully, but these errors were encountered: