import datetime
from myflaskapp import celery
from models.model import Auction
from controllers.auction_controller import AuctionController
from celery import chain
from celery.result import AsyncResult

def set_countdown(id, delay):
    return chain(set_active.si(id).set(eta=delay), deactivate.si(id).set(countdown=10))()
@celery.task()
def set_active(id):
    '''
    Called when an auction first becomes active, and when the end time for an auction is reached,
    and then takes actions to maintain the state of the auction properly.
    '''
    # if this is the first heartbeat, take care of activating the auction
    auction = Auction.query.filter_by(id=id).first()
    auction.active = True
    auction.put()

@celery.task(bind=True)
def deactivate(self, id):
    auction = Auction.query.filter_by(id=id).first()
    if not AuctionController.invoke_autobidders(auction):
        AuctionController.close_auction(auction)
    else:
        self.apply_async((id), countdown=10)

@celery.task
def cancel(task_id):
    AsyncResult(task_id).revoke()
ddf18ac8eed85cf890e0465d7b58268354848eec
<mask token>


@celery.task()
def set_active(id):
    """
    Called when an auction first becomes active, and when the end time for an auction is reached,
    and then takes actions to maintain the state of the auction properly.
    """
    auction = Auction.query.filter_by(id=id).first()
    auction.active = True
    auction.put()


@celery.task(bind=True)
def deactivate(self, id):
    auction = Auction.query.filter_by(id=id).first()
    if not AuctionController.invoke_autobidders(auction):
        AuctionController.close_auction(auction)
    else:
        self.apply_async(id, countdown=10)


<mask token>

<mask token>


def set_countdown(id, delay):
    return chain(set_active.si(id).set(eta=delay), deactivate.si(id).set(
        countdown=10))()


@celery.task()
def set_active(id):
    """
    Called when an auction first becomes active, and when the end time for an auction is reached,
    and then takes actions to maintain the state of the auction properly.
    """
    auction = Auction.query.filter_by(id=id).first()
    auction.active = True
    auction.put()


@celery.task(bind=True)
def deactivate(self, id):
    auction = Auction.query.filter_by(id=id).first()
    if not AuctionController.invoke_autobidders(auction):
        AuctionController.close_auction(auction)
    else:
        self.apply_async(id, countdown=10)


<mask token>

<mask token>


def set_countdown(id, delay):
    return chain(set_active.si(id).set(eta=delay), deactivate.si(id).set(
        countdown=10))()


@celery.task()
def set_active(id):
    """
    Called when an auction first becomes active, and when the end time for an auction is reached,
    and then takes actions to maintain the state of the auction properly.
    """
    auction = Auction.query.filter_by(id=id).first()
    auction.active = True
    auction.put()


@celery.task(bind=True)
def deactivate(self, id):
    auction = Auction.query.filter_by(id=id).first()
    if not AuctionController.invoke_autobidders(auction):
        AuctionController.close_auction(auction)
    else:
        self.apply_async(id, countdown=10)


@celery.task
def cancel(task_id):
    AsyncResult(task_id).revoke()

import datetime
from myflaskapp import celery
from models.model import Auction
from controllers.auction_controller import AuctionController
from celery import chain
from celery.result import AsyncResult


def set_countdown(id, delay):
    return chain(set_active.si(id).set(eta=delay), deactivate.si(id).set(
        countdown=10))()


@celery.task()
def set_active(id):
    """
    Called when an auction first becomes active, and when the end time for an auction is reached,
    and then takes actions to maintain the state of the auction properly.
    """
    auction = Auction.query.filter_by(id=id).first()
    auction.active = True
    auction.put()


@celery.task(bind=True)
def deactivate(self, id):
    auction = Auction.query.filter_by(id=id).first()
    if not AuctionController.invoke_autobidders(auction):
        AuctionController.close_auction(auction)
    else:
        self.apply_async(id, countdown=10)


@celery.task
def cancel(task_id):
    AsyncResult(task_id).revoke()

import datetime
from myflaskapp import celery
from models.model import Auction
from controllers.auction_controller import AuctionController
from celery import chain
from celery.result import AsyncResult

def set_countdown(id, delay):
    return chain(set_active.si(id).set(eta=delay), deactivate.si(id).set(countdown=10))()
@celery.task()
def set_active(id):
    '''
    Called when an auction first becomes active, and when the end time for an auction is reached,
    and then takes actions to maintain the state of the auction properly.
    '''
    # if this is the first heartbeat, take care of activating the auction
    auction = Auction.query.filter_by(id=id).first()
    auction.active = True
    auction.put()

@celery.task(bind=True)
def deactivate(self, id):
    auction = Auction.query.filter_by(id=id).first()
    if not AuctionController.invoke_autobidders(auction):
        AuctionController.close_auction(auction)
    else:
        self.apply_async((id), countdown=10)

@celery.task
def cancel(task_id):
    AsyncResult(task_id).revoke()