Skip to content

Instantly share code, notes, and snippets.

@drjackild
drjackild / pattern_matching.py
Created February 27, 2021 14:24
The usage of new pattern matching in Python
class Response:
def __init__(self, content: dict, status: int):
self.content = content
self.status = status
def make_request(content: dict, status: int) -> Response:
return Response(content, status)
"""
Backoff policy for agile retrying with increasing delay
"""
import asyncio
import logging
from typing import Awaitable, Callable
logger = logging.getLogger(__name__)
use anyhow::Result;
use redis::Commands;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::fmt::Formatter;
use std::str::FromStr;
const COORDINATE_PRECISION: usize = 4;
const CACHE_TTL: usize = 2628000;