Fix worker transaction

This commit is contained in:
Adolfo Gómez 2014-05-14 07:40:59 +00:00
parent 051bf0358b
commit 52b78f11a3

View File

@ -59,11 +59,11 @@ class AssignedAndUnused(Job):
osm = ds.osmanager.getInstance() osm = ds.osmanager.getInstance()
if osm.processUnusedMachines is True: if osm.processUnusedMachines is True:
logger.debug('Processing unused services for {0}'.format(osm)) logger.debug('Processing unused services for {0}'.format(osm))
for us in ds.assignedUserServices().select_for_update().filter(in_use=False, state_date__lt=since_state, state=State.USABLE, os_state=State.USABLE): for us in ds.assignedUserServices().select().filter(in_use=False, state_date__lt=since_state, state=State.USABLE, os_state=State.USABLE):
logger.debug('Found unused assigned service {0}'.format(us)) logger.debug('Found unused assigned service {0}'.format(us))
osm.processUnused(us) osm.processUnused(us)
else: # No os manager, simply remove unused services in specified time else: # No os manager, simply remove unused services in specified time
with transaction.atomic(): with transaction.atomic():
for us in ds.assignedUserServices().select_for_update().filter(in_use=False, state_date__lt=since_state, state=State.USABLE, os_state=State.USABLE): for us in ds.assignedUserServices().select().filter(in_use=False, state_date__lt=since_state, state=State.USABLE, os_state=State.USABLE):
logger.debug('Found unused assigned service {0}'.format(us)) logger.debug('Found unused assigned service {0}'.format(us))
us.remove() us.remove()