This file contains hidden or 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
class MyMeta(type): | |
def __new__(cls, name, bases, dct): | |
print "meta: creating %s %s" % (name, bases) | |
for pkls in bases: | |
for key, value in pkls.__dict__.items(): | |
if isinstance(value, Field): | |
pass | |
#print name,value | |
#setattr(kls, key, value) | |
kls = type.__new__(cls, name, bases, dct) |
This file contains hidden or 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
exc_type, exc_val, tb = sys.exc_info() | |
raise CustomError("oops," +str(e), ["AAA", "BBB"]), None, tb |
This file contains hidden or 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
# vi: set ts=2 sw=2: | |
version: '3.4' | |
services: | |
rabbitmq: | |
image: rabbitmq:3.7-management | |
volumes: | |
- ./rabbitmq:/var/lib/rabbitmq | |
ports: | |
- 5672:5672 | |
- 15672:15672 |
This file contains hidden or 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
""" | |
python3有concurrent.futures新功能可以做JobQueuePool的機制 | |
""" | |
import concurrent.futures | |
import requests # This is not standard library | |
URLS = [ | |
'https://docs.python.org/3/library/ast.html', | |
'https://docs.python.org/3/library/abc.html', | |
'https://docs.python.org/3/library/time.html', |
This file contains hidden or 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 os | |
import atexit | |
def keep_single_process(): | |
pid = str(os.getpid()) | |
pidfile = "/tmp/main_coupang.pid" | |
if os.path.isfile(pidfile): | |
raise Exception("%s already exists, exiting" % pidfile) | |
with open(pidfile, 'w') as fp: |
This file contains hidden or 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 math | |
def _get_chunks(chunk_size=4, chars=None): | |
if not chars: | |
# chars = list('0123456789') # list('-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz') | |
chars = list('-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz') | |
m = chars_size = len(chars) | |
output_size = 1 | |
while m < chunk_size: |
This file contains hidden or 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 multiprocessing as mp | |
import time | |
import random | |
import traceback | |
import threading | |
import Queue | |
import os | |
import logging | |
This file contains hidden or 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 yaml | |
import configparser | |
# print(dir(yaml)) | |
data = yaml.load(""" | |
a: | |
a1: a1 | |
a2: a2 | |
a3: "%(a1)s-%(a2)s" | |
b: | |
b1: b1 |
This file contains hidden or 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 jboss/keycloak:4.1.0.Final | |
USER root | |
RUN yum install -y iproute | |
USER jboss | |
COPY docker-entrypoint.sh docker-entrypoint.sh | |
COPY srv/jdbc-ping.cli /srv/jdbc-ping.cli | |
# COPY jdbc-ping.sh keycloak/bin/jdbc-ping.sh |
This file contains hidden or 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 csv | |
with open(file) as fp: | |
reader = csv.DictReader(fp, delimiter=',', lineterminator="\r\n",quotechar='"') | |
for row in reader: | |
src_data.append(row) |