Opened 4 years ago

Closed 4 years ago

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

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by milosu

Changed 4 years ago by milosu

comment:1 Changed 4 years ago by milosu

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

  • Has patch set

comment:3 Changed 4 years ago by codemonkey

  • milestone set to 1.3

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

comment:4 Changed 4 years ago by anonymous

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

comment:5 Changed 4 years ago by arthur78

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

comment:6 Changed 4 years ago by Honza_Kral

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:7 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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