- Install dependencies with
pip install -r requirements.txt
- Fill up the queue by running
python tasks.py 500
- Start Celery with
celery -A tasks worker --loglevel=INFO -c 3
- Disconnect computer from internet until you receive a
CANCEL_TASKS_BY_DEFAULT
warning. This may take a couple minutes and you'll see several errors, but you have to wait until the warning. - Reconnect to the internet. After a couple seconds, Celery will reconnect and tasks will start flowing again.
- Let tasks run for about a minute. You'll notice a slight slowdown and then suddenly tasks will stop entirely for a couple minutes, before resuming again.
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 json | |
from dataclasses import dataclass, is_dataclass, asdict | |
class DataclassEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if is_dataclass(obj): | |
return asdict(obj) | |
return super().default(obj) |
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 timeit | |
from abc import ABC, abstractmethod | |
class A(ABC): | |
@abstractmethod | |
def a(self): | |
... | |
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
# Mount the data disk | |
# Adapted from https://gist.github.com/ctompkinson/30f570882af38879b36fc7bffe3d1a60 | |
device=/dev/sdh | |
mount_point=/monitor-config | |
apt-get install -y nvme-cli | |
while [ true ]; do | |
for blkdev in $(nvme list | awk '/^\/dev/ { print $1 }'); do | |
mapping=$(nvme id-ctrl --raw-binary "${blkdev}" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g') | |
if [ ${mapping} = ${device} ]; then | |
echo "Found $device on $blkdev" |
I hereby claim:
- I am luhn on github.
- I am luhn (https://keybase.io/luhn) on keybase.
- I have a public key whose fingerprint is 8E57 AB5E 6FB9 441F 92C4 C3D8 9234 9742 8E86 184E
To claim this, I am signing this object:
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
version: "3.7" | |
services: | |
src: | |
build: | |
context: . | |
dockerfile: src.Dockerfile | |
dst: | |
build: |
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 sys | |
import inspect | |
def wrap(func): | |
attach() | |
return func | |
def attach(): |
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
# Interfaces | |
class IUserIdentity: | |
userid = None | |
class IIdentityPolicy: | |
def __call__(request): | |
""" Return the claimed identity of the user associated with the given |
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
mymeasure,context=baz,view=3 duration=0.743992881887 1493397808910022759 | |
mymeasure,context=foo,view=4 duration=0.340297307361 1493397809442500681 | |
mymeasure,context=bar,view=2 duration=0.351295066647 1493397809994147837 | |
mymeasure,context=bar,view=1 duration=0.485869769473 1493397810730819905 | |
mymeasure,context=bar,view=1 duration=0.104839181702 1493397810993959410 |
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
""" | |
Inspect a Pyramid app using URL traversal and construct URLs for all the views. | |
""" | |
def get_resources(self, root): | |
resources = { | |
type(root): root, | |
} | |
for resource in root.values(): | |
resources.update(self.get_resources(resource)) |
NewerOlder