Forums

multiprocessing with django web app doesn't working

Hello there! I am just trying create background process of checking payment on my online shop. It cool working on local machine, but on a python anywhere, I am getting endless loading of page, where this part of code start working. Part where "if == "WAITING": continue " - As if using the main process instead of the secondary one

def create_pay_url(value, comment, description, new_order, model, item_pk):
    try:
        pay_url, bill_id, response = conn.create_bill(value=value, comment=comment, description=description)
        c = multiprocessing.Process(target=check_payment, args=(bill_id, response, new_order, model, item_pk))
        c.start()

        return pay_url
    except Exception as e:
        logger = getLogger("except_logger")
        logger.exception(e)
        try:
            conn.remove_bill(bill_id)
        except:
            pass


def check_payment(bill_id, res, order, product_model, item_pk):
        try:
            user_order = model_communication_map[product_model.__name__].objects.get(pk=order.pk)

            while True:
                time.sleep(3)
                status, response = conn.check_bill(bill_id)
                if status == "PAID":
                    user_order.update(is_paid=True)

                    result = "Оплачено"
                    send_product(user_order, product_model, item_pk, amount=int(order.amount))
                    break
                elif status == "WAITING":
                    continue # this part 
                else:
                    user_order.delete()
                    result = "Отклонено / просрочено"
                    break

            return result
        except Exception as e:
            logger = getLogger("except_logger")
            logger.exception(e)
            conn.remove_bill(bill_id)
            return redirect("main")