Skip to content

Instantly share code, notes, and snippets.

@hoefling
hoefling / schema.py
Created May 6, 2020 19:48 — forked from miikka/schema.py
Using Hypothesis to generate XML based on RELAX-NG
import string
from lxml import etree
from lxml.etree import QName
from lxml.builder import E
from hypothesis import strategies as st
NS = "http://relaxng.org/ns/structure/1.0"
@hoefling
hoefling / async.py
Created January 20, 2020 17:05 — forked from phizaz/async.py
Python turn sync functions to async (and async to sync)
import functools
def force_async(fn):
'''
turns a sync function to async function using threads
'''
from concurrent.futures import ThreadPoolExecutor
import asyncio
pool = ThreadPoolExecutor()
@hoefling
hoefling / wsgi_bjoern.py
Created July 24, 2019 19:53 — forked from gcavalcante8808/wsgi_bjoern.py
Bjoern Django Final
import bjoern
import os, signal
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
app = get_wsgi_application()
NUM_WORKERS = 8
@hoefling
hoefling / conftest.py
Created August 28, 2018 10:00 — forked from asfaltboy/conftest.py
A pytest fixture to test Django data migrations
# based on https://gist.github.com/blueyed/4fb0a807104551f103e6
# and on https://gist.github.com/TauPan/aec52e398d7288cb5a62895916182a9f (gistspection!)
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
import pytest
@pytest.fixture()