sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
make check
sudo make install
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 boto.ec2.cloudwatch import CloudWatchConnection | |
| from datetime import datetime | |
| from main.settings import AWS_CREDENTIALS, CLOUDWATCH_NAMESPACE | |
| def monitor(app): | |
| cloudwatch = CloudWatchConnection(**AWS_CREDENTIALS) | |
| state = app.events.State() | |
| def get_task(event): |
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
| #!/usr/bin/env python | |
| import sys | |
| from celery.task.control import inspect | |
| def ping_celery(): | |
| ins = inspect() | |
| # Count the number of total worker processes | |
| total_workers = 0 | |
| # ... and active tasks |
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
| # Example usage: | |
| # with temporary_settings(CELERY_ALWAYS_EAGER=True): | |
| # run_task.delay() # runs task with eager setting enabled. | |
| from contextlib import contextmanager | |
| from django.conf import settings | |
| @contextmanager | |
| def temporary_settings(**temp_settings): | |
| orig_settings = {} |
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 logging | |
| import multiprocessing | |
| import time | |
| import mplog | |
| FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s' | |
| logging.basicConfig(level=logging.DEBUG, format=FORMAT) | |
| existing_logger = logging.getLogger('x') |
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
| # coding=utf8 | |
| # Copyright (C) 2011 Saúl Ibarra Corretgé <saghul@gmail.com> | |
| # | |
| import hashlib | |
| import os | |
| import re | |
| import socket | |
| import struct |
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
| #!/usr/bin/env bash | |
| sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test | |
| sudo apt update | |
| sudo update-alternatives --remove-all gcc | |
| sudo update-alternatives --remove-all g++ | |
| sudo apt-get install -y gcc-4.8 g++-4.8 gcc-4.9 g++-4.9 gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 |
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 select import select | |
| import os | |
| import time | |
| import subprocess | |
| from contextlib import contextmanager | |
| @contextmanager | |
| def pipe(): | |
| r, w = os.pipe() |
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 multiprocessing import Process | |
| class CatchableProcess(Process): | |
| def __init__(self, target, args=[], kwargs=dict()): | |
| from multiprocessing import Queue | |
| self.error = Queue(1) | |
| self.result = Queue(1) | |
| def wrapper(target, args, kwargs): | |
| try: |
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 functools | |
| def force_async(fn): | |
| ''' | |
| turns a sync function to async function using threads | |
| ''' | |
| from concurrent.futures import ThreadPoolExecutor | |
| import asyncio | |
| pool = ThreadPoolExecutor() |
NewerOlder