From 4ad8f20c28bf883ed64c42eb7b6e5590f08a729e Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Wed, 22 Aug 2018 21:44:00 -0700 Subject: [PATCH] billing: Add comment explaining race condition in customer creation. --- zilencer/lib/stripe.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zilencer/lib/stripe.py b/zilencer/lib/stripe.py index 1a0137d019..ff93fba90d 100644 --- a/zilencer/lib/stripe.py +++ b/zilencer/lib/stripe.py @@ -138,6 +138,10 @@ def extract_current_subscription(stripe_customer: stripe.Customer) -> Any: @catch_stripe_errors def do_create_customer_with_payment_source(user: UserProfile, stripe_token: str) -> stripe.Customer: realm = user.realm + # We could do a better job of handling race conditions here, but if two + # people from a realm try to upgrade at exactly the same time, the main + # bad thing that will happen is that we will create an extra stripe + # customer that we can delete or ignore. stripe_customer = stripe.Customer.create( description="%s (%s)" % (realm.string_id, realm.name), email=user.email,