Keep in mind your code guys is semantically different from the one of the 
first post.

In the first post, the _populate method can be called more than once, and 
if the time window is long enough, the two or more calls will eventually 
run the # ... populate code again, but on your code, the populate code will 
only be called once doesn't matter how many times you call _populate, 
unless the populated variable is restarted somewhere else. So I don't know 
how is this exactly used but make sure to check it

El martes, 12 de julio de 2016, 14:58:12 (UTC-3), Aymeric Augustin escribió:
>
> On 12 Jul 2016, at 19:46, Florian Apolloner <[email protected] 
> <javascript:>> wrote:
>
>
> On Tuesday, July 12, 2016 at 9:25:37 AM UTC+2, Aymeric Augustin wrote:
>>
>> Can you check the condition inside the lock? The following pattern seems 
>> simpler to me:
>>
>
> The standard pattern in such cases is to check inside and outside. Outside 
> to avoid the lock if you already populated (the majority of requests) and 
> inside to see if another thread populated it in the time you waited to get 
> the lock…
>
>
> Yes, actually that’s what I did the last time I implemented this pattern, 
> in Apps.populate.
>
> -- 
> Aymeric.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/cfbb3858-cbc7-4d90-b7a7-ca4656f131e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to