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 ujson | |
import sys | |
def test_does_not_leak_dictionary_values(): | |
import gc | |
gc.collect() | |
value = ["abc"] | |
data = {"1": value} | |
ref_count = sys.getrefcount(value) | |
ujson.dumps(data) |
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
# -*- coding: utf-8 -*- | |
# When running in a local back-end, both ElasticSearch and ElastAlert run | |
# inside Docker containers that are launched side-by-side (e.g. via | |
# `docker-compose` or K8S). Unfortunately, ElastAlert does not account for | |
# this and requires that the `elastalert_status` index be created before | |
# ElastAlert starts. In addition, when running via `docker-compose`, there is | |
# no automatic restart when the `elastalert` command crashes on start. | |
# |
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
# -*- coding: utf-8 -*- | |
import logging | |
import psutil | |
import threading | |
import time | |
from contextlib import contextmanager | |
from functools import partial |
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
# -*- coding: utf-8 -*- | |
import logging | |
import os | |
import time | |
from binascii import hexlify | |
from contextlib import ( | |
contextmanager, |
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 itertools | |
def scan(c, pattern, n): | |
"""Find up to N Redis keys that match a pattern. | |
NOTE: even if this Python code looks innocuous, it involves | |
A LOT of work on the Redis instance, especially when | |
the number of matches is low with respect to the total | |
number of keys. Use with care! | |
""" |
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
# -*- coding: utf-8 -*- | |
import docker | |
import os | |
import re | |
def readfile(path): | |
"""Read a UTF-8 encoded text file from disk.""" |
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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import errno | |
import glob | |
import json | |
import os | |
import requests |
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
from collections import defaultdict | |
def dicttree(): | |
return defaultdict(dicttree) |
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
# This will print nothing because the set contains tasks, not f1 and f2. | |
import asyncio | |
async def foo(): | |
return 'foo' | |
async def bar(): | |
f1 = foo(); | |
f2 = foo(); |
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
[run] | |
source = | |
greet | |
[paths] | |
source = | |
. | |
.tox/py27/lib/python2.7/site-packages/ | |
.tox/py34/lib/python3.4/site-packages/ | |
.tox/pypy/site-packages/ |
NewerOlder