Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#14533 closed (fixed)

django signals not thread-safe

Reported by: milosu Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django dispatcher.Signal methods connect and disconnect are not thread-safe, observed while using johnny cache

patch and test case attached

Attachments (2)

signals_ts.patch (1.9 KB ) - added by milosu 13 years ago.
signal_ts.py (771 bytes ) - added by milosu 13 years ago.

Download all attachments as: .zip

Change History (9)

by milosu, 13 years ago

Attachment: signals_ts.patch added

by milosu, 13 years ago

Attachment: signal_ts.py added

comment:1 by milosu, 13 years ago

attached test case should crash some threads with the following exception:

Exception in thread Thread-99:
Traceback (most recent call last):
  File "c:\Python26\lib\threading.py", line 532, in __bootstrap_inner
    self.run()
  File "signal_ts.py", line 25, in run
    signals.post_delete.disconnect(self.handler2, sender=None)
  File "c:\Python26\lib\site-packages\django_versions\trunk\django\dispatch\dispatcher.py", line 141, in disconnect
    del self.receivers[index]
IndexError: list assignment index out of range

attached patch solves this problem for me and passes django test suite

comment:2 by milosu, 13 years ago

Has patch: set

comment:3 by Maxim Bublis, 13 years ago

milestone: 1.3

This bug affects me too. Patch is working for me.

comment:4 by anonymous, 13 years ago

lock.release() should be done in a "finally:" cause.

comment:5 by Arthur, 13 years ago

This patch helped me, but I'm not an expert for threading problems :).

comment:6 by Honza Král, 13 years ago

Resolution: fixed
Status: newclosed

(In [14662]) Fixed #14533 -- Make django signals more thread-safe. Thanks milosu for the patch!

comment:7 by Jacob, 12 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top