ich möchte folgendes Ausgangssituation umbauen. Ich habe ein Python-File welches schaut ob neue Daten da. Falls ja, werden diese an ein weiteres File gegeben, damit diese verarbeitet werden.
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import subprocess
def get_input_files(directory):
new_files = list()
for subdir, dirs, files in os.walk(directory, followlinks=True):
for f in files:
new_files.append(os.path.join(subdir, f))
return new_files
def start_process(files_to_process):
for f in files_to_process:
subprocess.Popen(['python', 'process_data.py', '-i', f])
def main():
files_to_process = get_input_files('input')
start_process(files_to_process)
if __name__ == '__main__':
main()
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
def process_data(input_file):
pass
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-i', dest='input_file', action='store')
args = parser.parse_args()
if args.input_file is None:
parser.print_help()
else:
process_data(args.input_file)
if __name__ == '__main__':
main()
So recht weiter komme ich da aber nicht. Jemand eine Idee wie man da am Besten ansetzt? Braucht man bei ``multiprocessing.Pool`` wirklich immer einen Rückgabewert bei der Funktion?