polygon selector

import matplotlib.pyplot as plt from matplotlib.widgets import PolygonSelector # To create the polygon programmatically fig, ax = plt.subplots() fig.show() selector = PolygonSelector(ax, lambda *args: None)

matplotlib radio buttons

Using radio buttons to choose properties of your plot. Radio buttons let you choose between multiple options in a visualization. In this case, the buttons let the user choose one of the three different sine waves to be shown in the plot.

sanic delayed response

from asyncio import sleep from sanic import Sanic, response app = Sanic("DelayedResponseApp", strict_slashes=True) app.config.AUTO_EXTEND = False

sanic exception monitoring

from sanic.exceptions import SanicException from sanic.handlers import ErrorHandler class CustomHandler(ErrorHandler): def default(self, request, exception): # Here, we have access to the exception object

sanic logging

import logging from sanic import Sanic, text logging_format = "[%(asctime)s] %(process)d-%(levelname)s " logging_format += "%(module)s::%(funcName)s():l%(lineno)d: " logging_format += "%(message)s"

pytest-xdist example for sanic server

Install testing tools: $ pip install pytest pytest-xdist Run with xdist params: $ pytest examples/pytest_xdist.py -n 8 # 8 workers example import re import pytest

sanic raygun

from os import getenv from raygun4py.raygunprovider import RaygunSender from sanic import Sanic from sanic.exceptions import SanicException from sanic.handlers import ErrorHandler

sanic redirect

from sanic import Sanic, response app = Sanic("Example") @app.route("/") def handle_request(request):     return response.redirect("/redirect")

sanic request timeout

import asyncio from sanic import Sanic, response from sanic.config import Config from sanic.exceptions import RequestTimeout

sanic rollbar

pyrollbar is a Python SDK for reporting exceptions, errors, and log messages to Rollbar. Install rollbar using pip pip install rollbar