This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import queue | |
import threading | |
import time | |
import random | |
NUM_WORKERS = 20 | |
class Worker(threading.Thread): | |
"""A worker thread.""" | |
def __init__(self, input, output=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
========================= | |
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] |
OlderNewer