0

Trying to get multiprocessing working but for some reason it only starts the first process right away. Not sure what I am doing wrong.

cda and cld collect system information and other log information. I want to run them in parallel. I have tried threading and processing but both start on the p1 right away and never load the rest.

def cda():

    while True:

        try:
            machine.collect_network_connections()
            send_machine()
            time.sleep(10)

        except Exception as excp:

            LOGGER.critical(str(excp))
            time.sleep(10)


def cld(log_obj):

    sender_obj = LogSender()
    producer_obj = sender_obj.make_producer()

    while True:
        try:
            sender_obj.send_log(log_obj, producer_obj)

        except KeyboardInterrupt:
            LOGGER.info("Exited cleanly with KeyboardInterrupt.")
            sys.exit(0)

        except TypeError as te:
            LOGGER.error(te)
            pass

        time.sleep(2)


def main():

    p1 = Process(target=cda())

    process_list = list()

    for x in config.log_list:
        process_list.append(Process(target=cld(),args=(x,)))

    process_list.append(p1)
    for o in process_list:
        o.start()
martineau
  • 119,623
  • 25
  • 170
  • 301
Brain Monkey
  • 124
  • 8

0 Answers0