1717from django .conf import settings
1818from django .contrib .auth .models import User
1919from django .core .exceptions import ValidationError
20- from django .db import models , connections
20+ from django .db import models
2121from django .db .models import Max
2222from django .db .models .signals import post_delete
2323from django .db .models .signals import post_save
@@ -39,20 +39,6 @@ def log_event(app, msg, level=logging.INFO):
3939 logger .log (level , msg )
4040
4141
42- def close_db_connections (func , * args , ** kwargs ):
43- """
44- Decorator to close db connections during threaded execution
45-
46- Note this is necessary to work around:
47- https://code.djangoproject.com/ticket/22420
48- """
49- def _inner (* args , ** kwargs ):
50- func (* args , ** kwargs )
51- for conn in connections .all ():
52- conn .close ()
53- return _inner
54-
55-
5642def validate_app_structure (value ):
5743 """Error if the dict values aren't ints >= 0."""
5844 try :
@@ -348,7 +334,6 @@ def _get_command(self):
348334 def _command_announceable (self ):
349335 return self ._command .lower () in ['start web' , '' ]
350336
351- @close_db_connections
352337 @transition (field = state , source = INITIALIZED , target = CREATED )
353338 def create (self ):
354339 image = self .release .image
@@ -361,14 +346,12 @@ def create(self):
361346 use_announcer = self ._command_announceable (),
362347 ** kwargs )
363348
364- @close_db_connections
365349 @transition (field = state ,
366350 source = [CREATED , UP , DOWN ],
367351 target = UP , crashed = DOWN )
368352 def start (self ):
369353 self ._scheduler .start (self ._job_id , self ._command_announceable ())
370354
371- @close_db_connections
372355 @transition (field = state ,
373356 source = [INITIALIZED , CREATED , UP , DOWN ],
374357 target = UP ,
@@ -394,12 +377,10 @@ def deploy(self, release):
394377 # destroy old container
395378 self ._scheduler .destroy (old_job_id , self ._command_announceable ())
396379
397- @close_db_connections
398380 @transition (field = state , source = UP , target = DOWN )
399381 def stop (self ):
400382 self ._scheduler .stop (self ._job_id , self ._command_announceable ())
401383
402- @close_db_connections
403384 @transition (field = state ,
404385 source = [INITIALIZED , CREATED , UP , DOWN ],
405386 target = DESTROYED )
0 commit comments