# -*- encoding: utf-8 -*-

import multiprocessing as mp
import time
from pudb.remote import set_trace


def worker(worker_id):
    """ Simple worker process"""
    i = 0
    while i < 10:
        if worker_id == 1:  # debug process with id 1
            set_trace(term_size=(80, 24))
        time.sleep(1)  # represents some work
        print('In Process {}, i:{}'.format(worker_id, i))
        i = i + 1


if __name__ == '__main__':
    processes = []
    for p_id in range(2):  # 2 worker processes
        p = mp.Process(target=worker, args=(p_id,))
        p.start()
        processes.append(p)

    for p in processes:
        p.join()

[((292, 305), 'time.sleep', 'time.sleep', (['(1)'], {}), '(1)\n', (302, 305), False, 'import time\n'), ((514, 553), 'multiprocessing.Process', 'mp.Process', ([], {'target': 'worker', 'args': '(p_id,)'}), '(target=worker, args=(p_id,))\n', (524, 553), True, 'import multiprocessing as mp\n'), ((254, 283), 'pudb.remote.set_trace', 'set_trace', ([], {'term_size': '(80, 24)'}), '(term_size=(80, 24))\n', (263, 283), False, 'from pudb.remote import set_trace\n')]