Check polling¶
Polling is a method of receiving updates by periodically sending requests.
Once check status is changed to
ACTIVATED,
polling manager will call the
check_activated handler.
Check polling uses the /getChecks method.
Attention
Polling manager has
configuration
that defines the delay (between requests)
and timeout
for each check in the awaiting queue.
After the timeout polling manager will stop polling that check
and call the check_expired handler
if it is declared.
Default is 2 seconds delay and 300 seconds (5 min) timeout.
Usage example¶
import asyncio
from aiosend import CryptoPay
from aiosend.types import Check
cp = CryptoPay("TOKEN")
@cp.check_activated()
async def check_handler(check: Check, payload: str) -> None:
print("Received", check.amount, check.asset, payload)
@cp.check_expired()
async def expired_check_handler(check: Check, payload: str) -> None:
print("Expired check", check.check_id, payload)
async def main() -> None:
check = await cp.create_check(1, "USDT")
print("check link:", check.check_id)
check.poll(payload="payload")
await cp.start_polling()
if __name__ == "__main__":
asyncio.run(main())