2021-11-26

Python threads run in parallel when in Docker container, but run sequentially when container is run on Google Cloud Run

first post on SO, let me know how I can improve my question.

1. Summary

Goal: My app is a Craigslist scraper, it finds new posts and sends the feed to the user's email. It has a main thread that always listens to requests, and a worker thread, managed by the main thread, and is either working or sleeping.

Expected vs Actual Results: As mentioned in the title, the app works fine in the container locally, but when it's hosted on Cloud Run, the output and side-effects of the worker thread are deferred until the worker thread is killed.

It seems like the worker thread is only started when the main thread calls to kill it, at which point the worker thread only does one iteration of its work and then kills itself.

No errors messages.

2. What I've tried.

I've tried changing some of the Cloud Run container environment settings, like increasing amount of memory and number of vCPUs.

settings

Please let me know what additional information would help.



from Recent Questions - Stack Overflow https://ift.tt/3raZFyz
https://ift.tt/eA8V8J

No comments:

Post a Comment