Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:56:58+00:00 2026-06-08T13:56:58+00:00

I am curious to know if it is possible to run a python script

  • 0

I am curious to know if it is possible to run a python script that calls a function as parallel child processes. I’m not sure I’m using these terms correctly so here’s a concept script fashioned from a bash script that does what I’m talking about.

import Zfunctions as Z
reload(Z)

def Parallel():
    statements
    calls to other functions in a general function file Z

#--------------
if '__name__' == '__main__':
    # Running this script in a linux cluster with 8 processing node available
    Parallel() &  #1st process sent to 1st processing node
    Parallell() & #2nd process sent to 2nd node
    .
    .
    .
    Parallell() & #8th process sent to 8th node
    wait

Now I know the ampersand (&) and “wait” are wrong here but in the bash it is the way to sent the process to the background and wait for these processes to finish. My question is now, hopefully clearer: Can this be done in python, and if so how?

Any help is appreciated.

/M

I have gotten some good help. I tested this modification my question above which tries to run 60 jobs that will process a huge amount of data and write the results to disk. All this is in a single python file that combines two for loops and a series of internal functions calls. The script fails and the error output is found below:

import multiprocessing

def Parallel(m,w,PROCESSES):                                                             
plist = {}                                                                           
plist['timespan'] = '2007-2008'                                                      
print 'Creating pool with %d processes\n' % PROCESSES                                
pool = multiprocessing.Pool(PROCESSES)                                               
print 'pool = %s' % pool                                                             

TASKS = [(LRCE,(plist,m,w)),(SRCE,(plist,m,w)),(ALBEDO,(plist,m,w)),                 
         (SW,(plist,m,w)),(RR,(plist,m,w)),(OLR,(plist,m,w)),(TRMM,(plist,w)),       
         (IWP,(plist,m,w)),(RH,(plist,'uth',m,w)),(RH,(plist,200,m,w)),              
         (RH,(plist,400,m,w)),(IWC,(plist,200,m,w)),(IWC,(plist,400,m,w)),           
         (CC,(plist,200,m,w)),(CC,(plist,400,m,w))]                                                                                                        

results = [pool.apply_async(calculate,t) for t in TASKS]                             
print 'Ordered results using pool.apply_async():'                                    
for r in results:                                                                    
    print '\t', r.get()                                                              

#-----------------------------------------------------------------------------------     
if __name__ == '__main__':                                                               
PROCESSES = 8                                                                        
for w in np.arange(2):                                                               
    for m in np.arange(2):                                                           
        Parallel(m,w,PROCESSES) 

#### error message from cluster

Exception in thread Thread-3:
Traceback (most recent call last):
File “/software/apps/python/2.7.2-smhi1/lib/python2.7/threading.py”, line 552, in bootstrap_inner
self.run()
File “/software/apps/python/2.7.2-smhi1/lib/python2.7/threading.py”, line 505, in run
self.__target(*self.__args, **self.__kwargs)
File “/software/apps/python/2.7.2-smhi1/lib/python2.7/multiprocessing/pool.py”, line 313, in _handle_tasks
put(task)
PicklingError: Can’t pickle : attribute lookup __builtin
.function failed

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:56:59+00:00Added an answer on June 8, 2026 at 1:56 pm

    You probably want to look into multiprocessing — your code could be accomplished as follows:

    import multiprocessing
    
    def Parallel(junk):    
        #...snip...
    
    if __name__ == "__main__":
       p = multiprocessing.Pool(8)
    
       results = p.map(Parallel, range(8))
    

    One warning: Don’t try this in an interactive interpreter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am curious to know that could it be possible that in the below
I am just curious to know the reason why it's not possible to host
I'm using VS2005 C# Server-side coding. I'm curious to know that in VS2005 version
I am curious to know is it possible to create a conditional not null
I am very curious to know if it is possible to replace the normal
Just curious to know that if my PC is infected with a Trojan or
I'm curious to know if this is actually possible... In this simplified example, I
I'm curious to know if it's possible to replace Spring.Net's built-in IoC container with
I was just curious to know if it is possible to have a pointer
I was just curious to know if it is possible to have a pointer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.