Skip to content

Instantly share code, notes, and snippets.

View olegborzov's full-sized avatar

Oleg Borzov olegborzov

View GitHub Profile
@olegborzov
olegborzov / marshmallow_to_openapi.py
Created February 22, 2021 17:59
Marshmallow to Sanic-Openapi converter
from typing import List
from marshmallow import fields, Schema
from sanic_openapi import doc
MAP_MARSHMALLOW_IN_OPEN_API = {
fields.DateTime: doc.DateTime,
fields.Date: doc.Date,
fields.Integer: doc.Integer,
@olegborzov
olegborzov / restartable_decorator.py
Last active October 18, 2018 14:36
Restartable decorator for python functions - sync and async versions
from asyncio import sleep as async_sleep
from datetime import time
import logging
from typing import Tuple, Callable
def restartable(max_attempts: int = 5,
delay: int = 0.5,
backoff: int = 2,
exceptions: Tuple[Exception] = (Exception,),