Configuring either threading or multiprocessing to run multiple scripts python
Question: I trying to run multiple scripts, I have one master script which I just
replace the name with and run.

The threading method i'm trying looks like this

    
    
    from threading import Thread
    import sys
    
    sys.path.append('/python/loanrates/master')
    
    names =  ['BTS', 'ETH', 'CLAM']#, 'DOGE', 'FCT', 'MAID', 'STR', 'XMR', 'XRP' ]
    threads = []
    for name in names: 
        sys.path.append('/python/loanrates/'+name)
    
    import Master
    
    for name in names:
        T = Thread(target=Master.main(name))
        print T
        threads.append(T)
    
    for thread_ in threads:
        thread_.start()
    
    for thread_ in threads:
        thread_.join()
    

But this only starts the first script, ie the first name in names 'BTS'

Using multiprocessing seems a lot simpler but this time it doesn't recognize
Pool

    
    
    import multiprocessing 
    import Master
    
    pool = Pool(processes= 2)
    
    names =  ['BTS', 'ETH']#, 'CLAM', 'DOGE', 'FCT', 'MAID', 'STR', 'XMR', 'XRP' ]
    
    pool.map(Master.main(), names)
    

Which would you recommend and what do I need to change the code to for it to
work ?


Answer: You want to send a function and it's arguments to the thread, not actually
call it in your context.

So change this:

    
    
    T = Thread(target=Master.main(name)) # actually calls Master.main(args)
    

To this:

    
    
    # send Master.main and arguemnts to the thread
    T = Thread(target=Master.main, args=(name,)) 
    

Same goes for `Pool.map`:

Change this:

    
    
    pool.map(Master.main(), names)
    

To this:

    
    
    pool.map(Master.main, names)
    

