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 6850275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:06:14+00:00 2026-05-27T01:06:14+00:00

I am using python 2.7, I have some code that looks like this: task1()

  • 0

I am using python 2.7, I have some code that looks like this:

task1()
task2()
task3()
dependent1()

task4()
task5()
task6()
dependent2()

dependent3()

The only dependencies here are as follows: dependent1 needs to wait for tasks1-3, dependent2 needs to wait for tasks 4-6 and dependent3 needs to wait for dependents1-2… The following would be okay: running the whole 6 tasks first in parallel, then the first two dependents in parallel.. then the final dependent

I prefer to have as much tasks as possible running in parallel, I’ve googled for some modules but I was hoping to avoid external libraries, and not sure how the Queue-Thread technique can solve my problem (maybe someone can recommend a good resource?)

  • 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-05-27T01:06:15+00:00Added an answer on May 27, 2026 at 1:06 am

    The builtin threading.Thread class offers all you need: start to start a new thread and join to wait for the end of a thread.

    import threading
    
    def task1():
        pass
    def task2():
        pass
    def task3():
        pass
    def task4():
        pass
    def task5():
        pass
    def task6():
        pass
    
    def dep1():
        t1 = threading.Thread(target=task1)
        t2 = threading.Thread(target=task2)
        t3 = threading.Thread(target=task3)
    
        t1.start()
        t2.start()
        t3.start()
    
        t1.join()
        t2.join()
        t3.join()
    
    def  dep2():
        t4 = threading.Thread(target=task4)
        t5 = threading.Thread(target=task5)
    
        t4.start()
        t5.start()
    
        t4.join()
        t5.join()
    
    def dep3():
        d1 = threading.Thread(target=dep1)
        d2 = threading.Thread(target=dep2)
    
        d1.start()
        d2.start()
    
        d1.join()
        d2.join()
    
    d3 = threading.Thread(target=dep3)
    d3.start()
    d3.join()
    

    Alternatively to join you can use Queue.join to wait for the threads end.

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

Sidebar

Related Questions

I have a script that I'd like to continue using, but it looks like
I have a binary file that I have to parse and I'm using Python.
I have some code to interface Python to C++ which works fine but every
I have a python script that makes a series of url calls using urllib2.
I have written some C++ code that generates a std::vector. I also have a
I am using the Python code at the bottom of this question to send
I have a python logger set up, using python's logging module. I want to
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something
When using Python's super() to do method chaining, you have to explicitly specify your
I have been trying to make a case for using Python at my work.

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.