Opened 12 years ago

Closed 12 years ago

#4909 closed (fixed)

WSGIHandler is not threadsafe

Reported by: colin@… Owned by: Jacob
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The call method of WSGIHandler is called from multiple threads, however there code that checks for the middleware being setup is not thread safe.

{{{if self._request_middleware is None:


Multiple threads can launch into load_middleware at once, leading to corrupt lists.

The attached patch uses a lock to protect the middleware loading if it's required.

Attachments (1)

wsgi-thread-safe-init.patch (1.1 KB) - added by colin@… 12 years ago.

Download all attachments as: .zip

Change History (3)

Changed 12 years ago by colin@…

Attachment: wsgi-thread-safe-init.patch added

comment:1 Changed 12 years ago by Simon G. <dev@…>

Has patch: set
Triage Stage: UnreviewedReady for checkin

comment:2 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [5868]) Fixed #4909 -- Fixed a race condition with middleware initialisation in multi-threaded setups. Thanks, colin@….

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