Cyberclops
Cyberclops

Reputation: 361

How do I limit access to a cloud storage bucket to one process at a time?

I am fairly new to GCP.

I have some items in a cloud storage bucket.

I have written some python code to access this bucket and perform update operations.

I want to make sure that whenever the python code is triggered, it has exclusive access to the bucket so that I do not run into some sort of race condition.

For example, if I put the python code in a cloud function and trigger it, I want to make sure it completes before another trigger occurs. Is this automatically handled or do I have to do something to prevent this? If I have to add something like a semaphore, will subsequent triggers happen automatically after the the semaphore is released?

Upvotes: 0

Views: 214

Answers (2)

Cyberclops
Cyberclops

Reputation: 361

All of the info supplied has been helpful. The best answer has been to use a max-concurrent-dispatches setting of 1 so that only one task is dispatched at a time.

Upvotes: 0

Sri
Sri

Reputation: 318

  • Google Cloud Scheduler is a fully managed cron jobs scheduling service available in GCP. It's basically the cron jobs which trigger at a given time. All you need to do is specify the frequency(The time when the job needs to be triggered) and the target(HTTP, Pub/Sub, App Engine HTTP) and you can specify the retry configuration like Max retry attempts, Max retry duration etc..
  • App Engine has a built-in cron service that allows you to write a simple cron.yaml containing the time at which you want the job to run and which endpoint it should hit. App Engine will ensure that the cron is executed at the time which you have specified. Here’s a sample cron.yaml that hits the /tasks/summary endpoint in AppEngine deployment every 24 hours.
  cron:
  - description: "daily summary job"
    url: /tasks/summary
    schedule: every 24 hours

Upvotes: 1

Related Questions