Fix startup crash by importing pyotp lazily inside function

This commit is contained in:
Thigazhezhilan J 2026-05-02 15:31:13 +05:30
parent e1759b14fa
commit f5762de2b4

View File

@ -1,10 +1,8 @@
import json
import threading
import time
from datetime import datetime, timedelta, timezone
from urllib.parse import parse_qs, urlparse
import pyotp
import requests
from app.services.crypto_service import decrypt_value, encrypt_value
@ -200,6 +198,7 @@ def _perform_zerodha_login(
request_id = login_data["data"]["request_id"]
# Step 2: TOTP — don't follow redirect automatically
import pyotp # imported here so missing package doesn't crash startup
totp_value = pyotp.TOTP(totp_secret).now()
twofa_resp = session.post(
KITE_TWOFA_ENDPOINT,