Exemplo n.º 1
0
 def __init__(self, callback=None,
         max_workers_in_memory=5000, max_tasks_in_memory=10000):
     self.workers = LocalCache(max_workers_in_memory)
     self.tasks = LocalCache(max_tasks_in_memory)
     self.event_callback = callback
     self.group_handlers = {"worker": self.worker_event,
                            "task": self.task_event}
     self._mutex = Lock()
Exemplo n.º 2
0
 def test_expires(self):
     limit = 100
     x = LocalCache(limit=limit)
     slots = list(range(limit * 2))
     for i in slots:
         x[i] = i
     self.assertListEqual(x.keys(), slots[limit:])
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     self.cache = LocalCache(5000)
Exemplo n.º 4
0
Arquivo: base.py Projeto: jokar/minion
 def __init__(self, *args, **kwargs):
     super(BaseDictBackend, self).__init__(*args, **kwargs)
     self._cache = LocalCache(
         limit=kwargs.get("max_cached_results") or conf.MAX_CACHED_RESULTS)
Exemplo n.º 5
0
import sys

from datetime import datetime

from celery.app import app_or_default
from celery.datastructures import LocalCache

TASK_NAMES = LocalCache(0xFFF)

HUMAN_TYPES = {
    "worker-offline": "shutdown",
    "worker-online": "started",
    "worker-heartbeat": "heartbeat"
}


def humanize_type(type):
    try:
        return HUMAN_TYPES[type.lower()]
    except KeyError:
        return type.lower().replace("-", " ")


class Dumper(object):
    def on_event(self, event):
        timestamp = datetime.fromtimestamp(event.pop("timestamp"))
        type = event.pop("type").lower()
        hostname = event.pop("hostname")
        if type.startswith("task-"):
            uuid = event.pop("uuid")
            if type.startswith("task-received"):