Python threading.Thread join hangs

0

We've got a Lambda function that runs in a Docker container (built from public.ecr.aws/lambda/python:3.8) that was working until we recently (02/11) deployed some minor changes to another Lambda function (CI redeploys everything). After some debugging, it looks like the code is stuck waiting for the threading.Thread join:

    thread_queue = queue.Queue()
    our_thread = threading.Thread(target=our_func, args=(thread_queue,))
  
    our_thread.start()
    print("Thread started and waiting...")
  
    our_thread.join()
    print("Thread completed")

The our_func updates our RDS database and writes to S3....both are working as expected.

We're not seeing "Thread completed" in the logs.

Why is the Lambda function hanging?

asked a year ago201 views
1 Answer
0

Maybe something in the thread itself that doesn't finish somehow?

If this is actually your code, why are you creating a thread?

profile pictureAWS
EXPERT
Uri
answered a year ago
  • Thanks for the response. A query update doubled the amount of time querying the database, which was enough to cause some of the threads to time out. Wasn't the easiest bug to find because it was failing some of the time. We're currently using threading because it's faster than sequential processing and cheaper than several Lambda functions.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions