Opened 9 years ago

Closed 9 years ago

#25779 closed Cleanup/optimization (fixed)

Redundant try block in WSGIHandler

Reported by: Attila Tovt Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Andrew Godwin Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In this code(

                    # Check that middleware is still uninitialized.
                    if self._request_middleware is None:
                except Exception:
                    # Unload whatever middleware we got
                    self._request_middleware = None

It seems there is no need for this try block, because self._request_middleware is being used as a flag of successful initialization completion.
Here where it gets assigned(

        # We only assign to this when initialization is complete as it is used
        # as a flag for initialization being complete.
        self._request_middleware = request_middleware

Maybe, there are some thread safety issues that I'm missing, in which case, I'm sorry for bothering.

Change History (5)

comment:1 by Tim Graham, 9 years ago

Cc: Andrew Godwin added
Summary: Redundant try blockRedundant try block in WSGIHandler

Andrew, I tracked that addition to the patch you committed in #11193 [ba585a2c6d]. Any insight?

comment:2 by Simon Charette, 9 years ago

It looks like this change predates the use of context managers in Django.

comment:3 by Claude Paroz, 9 years ago

Triage Stage: UnreviewedAccepted

The try block should probably have been removed during this commit: [e0fce8706d31f]

comment:4 by Attila Tovt, 9 years ago

Has patch: set

comment:5 by Attila Tovt <uran198@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 80927455:

Fixed #25779 -- Removed redundant try block in WSGIHandler

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