Opened 12 years ago
Closed 12 years ago
#19340 closed Bug (invalid)
django.forms.Field is not thread-safe
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.4 |
Severity: | Normal | Keywords: | thread-safe |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.forms.Field has the 'creation_counter' attribute which is incremented when an instance of django.forms.Field (or one of its subclasses) is created. I DO understand that it's a bit unusual to create
forms in the runtime, so this must not be a big issue (or not a bug at all), but it should be documented somewhere.
In [231]: from django import forms In [232]: forms.Field.creation_counter Out[232]: 0 In [233]: from threading import Thread In [234]: def f(): .....: for x in xrange(10000): .....: forms.Field() .....: In [235]: ths = [Thread(target=f) for x in xrange(4)] In [236]: for t in ths: t.start() In [237]: for t in ths: t.join() In [240]: forms.Field.creation_counter Out[240]: 35409
Note:
See TracTickets
for help on using tickets.
I'm not convinced this is a problem in practice. The creation counter is only used to establish field order, so as long as it's monotonically increasing on each form instance, it shouldn't matter than the values aren't sequential.
If you can demonstrate that it's a problem in practice, feel free to reopen.