#NEWLINE# @ task ( ) #NEWLINE# def start_server( event_id ) : #NEWLINE# #INDENT# event = TaskEvent . objects . filter ( pk = event_id ) #NEWLINE# if event : #NEWLINE# #INDENT# event = event [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# event . server . set_online ( ) #NEWLINE# if ( not event . repeat ) : #NEWLINE# #INDENT# event . status = 2 #NEWLINE# event . save ( update_fields = [ 'status' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_run = ( event . date + timedelta ( minutes = event . repeat ) ) #NEWLINE# if ( timezone . now ( ) >= next_run ) : #NEWLINE# #INDENT# event . status = 2 #NEWLINE# event . save ( update_fields = [ 'status' ] ) #NEWLINE# return #NEWLINE# #UNINDENT# task = start_server . apply_async ( ( event_id , ) , eta = next_run ) #NEWLINE# event . date = next_run #NEWLINE# event . task_id = task . task_id #NEWLINE# event . save ( update_fields = [ 'date' , 'task_id' ] )