Refs #28593 -- Made URLResolver._populate() more resilient to signal interrupts.
Refs #28593 -- Made URLResolver._populate() more resilient to signal interrupts.

_populate() sets the populating attribute to prevent infinite recursion in
case a urlconf includes itself. The flag is a threadlocal to avoid a race
condition [1] where one thread sets the flag and another checks it, then
proceeds to access data that's supposed to be populated (e.g. _reverse_dict)
but isn't yet.

The potential still exists for a thread to set the threadlocal, then be
interrupted by a signal such as SIGALRM and raise before resetting the
threadlocal flag. In this scenario, subsequent calls to _populate() in the
same thread will short-circuit erroneously.

The bulk of the method was already wrapped in a try/finally in df41b5a, but
since a signal interrupt can occur at any line executed by the interpreter,
this moves up the try to ensure threadlocal gets reset.

[1]: https://groups.google.com/d/msg/django-developers/D_bIeinKHjE/4NmVQUJqAgAJ

auvipy/django,felixxm/django,schinckel/django,piquadrat/django,googleinterns/django,frankvdp/django,django/django,solarissmoke/django,MarkusH/django,reinout/django,koordinates/django,monetate/django,claudep/django,charettes/django,claudep/django,dracos/django,monetate/django,theo-l/django,elena/django,ebar0n/django,freakboy3742/django,treyhunner/django,pauloxnet/django,kaedroho/django,ebar0n/django,takis/django,shacker/django,edmorley/django,georgemarshall/django,wkschwartz/django,timgraham/django,frankvdp/django,georgemarshall/django,edmorley/django,dracos/django,rsalmaso/django,EmadMokhtar/Django,rsalmaso/django,googleinterns/django,auvipy/django,claudep/django,koordinates/django,takis/django,manhhomienbienthuy/django,manhhomienbienthuy/django,schinckel/django,django/django,blighj/django,freakboy3742/django,fenginx/django,felixxm/django,schinckel/django,shaib/django,fenginx/django,dsanders11/django,manhhomienbienthuy/django,atul-bhouraskar/django,frankvdp/django,freakboy3742/django,apollo13/django,elena/django,timgraham/django,pauloxnet/django,adamchainz/django,manhhomienbienthuy/django,solarissmoke/django,charettes/django,dracos/django,adamchainz/django,piquadrat/django,frankvdp/django,wkschwartz/django,uranusjr/django,piquadrat/django,dsanders11/django,elena/django,kaedroho/django,simonw/django,wkschwartz/django,dsanders11/django,elena/django,reinout/django,ebar0n/django,dsanders11/django,uranusjr/django,fenginx/django,shacker/django,reinout/django,koordinates/django,MarkusH/django,simonw/django,atul-bhouraskar/django,shaib/django,EmadMokhtar/Django,fenginx/django,pauloxnet/django,blighj/django,rsalmaso/django,googleinterns/django,timgraham/django,treyhunner/django,charettes/django,timgraham/django,charettes/django,shaib/django,shaib/django,jpic/django,felixxm/django,django/django,uranusjr/django,dracos/django,felixxm/django,georgemarshall/django,MarkusH/django,monetate/django,EmadMokhtar/Django,edmorley/django,atul-bhouraskar/django,treyhunner/django,ghickman/django,simonw/django,jpic/django,pauloxnet/django,uranusjr/django,solarissmoke/django,auvipy/django,schinckel/django,blighj/django,reinout/django,apollo13/django,solarissmoke/django,wkschwartz/django,shacker/django,ghickman/django,adamchainz/django,ebar0n/django,theo-l/django,apollo13/django,theo-l/django,jpic/django,ghickman/django,shacker/django,piquadrat/django,auvipy/django,takis/django,django/django,jpic/django,googleinterns/django,georgemarshall/django,atul-bhouraskar/django,koordinates/django,edmorley/django,adamchainz/django,theo-l/django,apollo13/django,monetate/django,kaedroho/django,claudep/django,blighj/django,simonw/django,treyhunner/django,takis/django,rsalmaso/django,ghickman/django,MarkusH/django