def communicate(input, coro=None):
if platform.system() == 'Windows':
# asyncfile.Popen must be used instead of subprocess.Popen
pipe = asyncoro.asyncfile.Popen([r'\cygwin64\bin\sha1sum.exe'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
else:
pipe = subprocess.Popen(['sha1sum'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# convert pipe to asynchronous version
async_pipe = asyncoro.asyncfile.AsyncPipe(pipe)
# 'communicate' takes either the data or file descriptor with data
# (if file is too large to read in full) as input
input = open(input)
stdout, stderr = yield async_pipe.communicate(input)
print('communicate sha1sum: %s' % stdout)
评论列表
文章目录