Opened 6 years ago

Closed 6 years ago

Last modified 5 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: UI/UX:

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 6 years ago.
signal_ts.py (771 bytes) - added by milosu 6 years ago.

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by milosu

Attachment: signals_ts.patch added

Changed 6 years ago by milosu

Attachment: signal_ts.py added

comment:1 Changed 6 years ago by milosu

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 Changed 6 years ago by milosu

Has patch: set

comment:3 Changed 6 years ago by Maxim Bublis

milestone: 1.3

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

comment:4 Changed 6 years ago by anonymous

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

comment:5 Changed 6 years ago by Arthur

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

comment:6 Changed 6 years ago by Honza Král

Resolution: fixed
Status: newclosed

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

comment:7 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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