- cgcreate -g memory:/myGroup
- echo $(( 500 * 1024 * 1024 )) > /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes(
notes
: centos cgroup mount on /sys/fs/cgroup) - echo '@<username>:<command> memory /myGroup' >> /etc/cgrules.conf
- systemctl restart cgred
- cgget -g memory /myGroup (查看/myGroup的配置,以及内存使用情况)
- cat /proc//cgroup
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 ctypes import * | |
libc = cdll.LoadLibrary("libc.so.6") | |
class POINT(Structure): | |
_fields_ = ("x", c_int), ("y", c_int) | |
f = open("test_structure", "w") |
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 celery.task import periodic_task | |
from datetime import timedelta | |
# first way | |
@periodic_task(run_every=timedelta(seconds=10), exchange="default", routing_key="default") | |
def every_10_seconds(): | |
print("This is test") | |
return 1 | |
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 select | |
import threading | |
import time | |
class StoppableThread(threading.Thread): | |
"""Thread class with a stop() method. The thread itself has to check | |
regularly for the stopped() condition.""" | |
def __init__(self): |
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 celery.task import PeriodicTask | |
from datetime import timedelta | |
class Lmy(PeriodicTask): | |
run_every = timedelta(seconds=60) | |
#celery queue router | |
options = {"exchange": "default", "routing_key": "default"} | |
name = "xxxxx" |
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 threading | |
class Consumer(threading.Thread): | |
def __init__(self, sock): | |
super(Consumer, self).__init__() | |
self.sock = sock | |
def run(self): | |
while True: | |
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
# encoding=utf8 | |
import signal | |
import time | |
class TimeoutError(Exception): | |
pass | |
class Timeout(object): |
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 .celery import app | |
import heapq | |
import socket | |
from collections import UserDict | |
from functools import singledispatch, update_wrapper | |
from operator import itemgetter | |
from select import poll, POLLIN | |
from urllib.parse import urlparse | |
import httplib2 |
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
# encoding=utf8 | |
''' | |
https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/PostgreSQLInheritance | |
''' | |
from sqlalchemy import create_engine | |
from sqlalchemy.ext.declarative import as_declarative, declared_attr | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
engine = create_engine('postgresql:///test', convert_unicode=True, echo=False) |
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 socket | |
import sys | |
''' | |
The correct maximum UDP message size is 65507, | |
as determined by the following formula: 0xffff - (sizeof(IP Header) + sizeof(UDP Header)) = 65535-(20+8) = 65507 | |
http://stackoverflow.com/questions/1098897/what-is-the-largest-safe-udp-packet-size-on-the-internet | |
search gateway MTU: | |
ping -s 1500 -M do <gateway> | |
''' | |
messages = [b'x' * 65507] * 3 |
OlderNewer