Skip to content

Instantly share code, notes, and snippets.

View JohnSpeno's full-sized avatar
🦋
I may never respond.

John Speno JohnSpeno

🦋
I may never respond.
View GitHub Profile
import queue
import threading
import time
import random
NUM_WORKERS = 20
class Worker(threading.Thread):
"""A worker thread."""
def __init__(self, input, output=None):
import django
from django.db import transaction
from django.db.models import Count, Func, IntegerField, OuterRef, Subquery
from django.contrib.postgres.aggregates import ArrayAgg
from django.contrib.postgres.fields import ArrayField
from sql_util.utils import SubqueryAggregate
django.setup()
from pizza.models import Topping, Pizza
@JohnSpeno
JohnSpeno / durability.py
Created November 20, 2020 20:00 — forked from seddonym/durability.py
Durable decorator
import functools
from django.conf import settings
from django.db import transaction
def durable(func):
"""
Decorator to ensure that a function is not being called from an atomic block.
@JohnSpeno
JohnSpeno / join_promotion
Created May 23, 2023 22:21 — forked from akaariai/join_promotion
Django join promotion
=========================
Join promotion in the ORM
=========================
[NOTE: We need better terms than promote and demote for changing the join
type. These terms are extremely easy to mix up. Maybe the ORM methods could
be to_inner_joins and to_louter_joins instead of promote_joins and demote_joins?
I tried to clean up the mis-usages of promotion/demotion but there could still
be some cases where these are mixed up]