def mint_token_request(self, token_req_id, retry=False): """ :param self: :param token_req_id: :return: """ with redis.lock("tasks:all_kudos_requests", timeout=LOCK_TIMEOUT): with redis.lock("tasks:token_req_id:%s" % token_req_id, timeout=LOCK_TIMEOUT): from kudos.management.commands.mint_all_kudos import sync_latest from gas.utils import recommend_min_gas_price_to_confirm_in_time from dashboard.utils import has_tx_mined obj = TokenRequest.objects.get(pk=token_req_id) multiplier = 1 gas_price = int( float(recommend_min_gas_price_to_confirm_in_time(1)) * multiplier) if gas_price > delay_if_gas_prices_gt_mint and self.request.retries < self.max_retries: self.retry(countdown=120) return tx_id = obj.mint(gas_price) if tx_id: while not has_tx_mined(tx_id, obj.network): time.sleep(1) sync_latest(0) sync_latest(1) sync_latest(2) sync_latest(3) notify_kudos_minted(obj) else: self.retry(countdown=(30 * (self.request.retries + 1)))
# note: only use this if the admin is failling token_req_id = 2235 import time from dashboard.utils import has_tx_mined from gas.utils import recommend_min_gas_price_to_confirm_in_time from kudos.management.commands.mint_all_kudos import sync_latest from kudos.models import TokenRequest from marketing.mails import notify_kudos_minted obj = TokenRequest.objects.get(pk=token_req_id) multiplier = 1 gas_price = int( float(recommend_min_gas_price_to_confirm_in_time(1)) * multiplier) tx_id = obj.mint(gas_price) while not has_tx_mined(tx_id, obj.network): time.sleep(1) for i in range(0, 9): sync_latest(i, obj.network) notify_kudos_minted(obj)