Hi Balaji,
Sorry but I don't understand what do you mean with "If we put this code with necessary care".
All I can say is that your code is not thread safe and it may break. How likely is this to happen depends on the usage patterns of your app. How serious it will be depends on the leaked data. Depending on context/constraints it might be a perfectly good enough solution. It's up to you deciding if it's worth fixing it.
Another approach would be overriding get_form as shown in the django docs[1].
The point is that neither of those solutions makes changes to shared state (the admin).
HTH
Missatge de Balaji Shetty <balajishetty@gmail.com> del dia dv., 31 de maig 2019 a les 16:42:
Dear Alexis Roda SirThank You very Much.definitely Race Condition may arise if we do not put code inn critical section. But your suggested approach did not work and i found another alternative which is working fine. If we put this code with necessary care than will it be ok?On Tue, May 28, 2019 at 8:33 PM Alexis Roda <alexis.roda.villalonga@gmail.com> wrote:--No, it isn't. It's not thread safe.Changes in shared state in multi-threaded code may lead to race conditions[1].Depending on your usage it may be very unlikely, but under the right circumstances root may end up having some missing fields in the form or dgp may see fields that it is not intended to see.Either protect the critical section[2] with some kind of lock or, as I suggested in my previous answer, create non-shared (request local) state.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMDYoXa16C5goSadFbSoXQg1-v2zh9vrq%2BAk%3Dkqbq1rk%3DsgSQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
----Mr. Shetty Balaji S.
Asst. Professor
Department of Information Technology,SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.IndiaOfficial: bsshetty@sggs.ac.inMobile: +91-9270696267
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAECSbOvKUK0H2mrt_S%2BhmbVmmeneQXXc%2BR9a%3DFGHE7XOVmOK-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMDYoXb%3D7D99YNQrAos%2BVWaxqxq%2B4z9m_kw3nLPZ28bfrZ-Ujw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment