Esempio n. 1
0
import pika
import argparse
import logging
import traceback
import requests
import warnings
from requests.packages.urllib3 import exceptions
warnings.simplefilter('ignore', exceptions.InsecurePlatformWarning)

from ADSOrcid import app, importer, updater
from ADSOrcid.pipeline import GenericWorker
from ADSOrcid.pipeline import pstart
from ADSOrcid.utils import setup_logging, get_date
from ADSOrcid.models import ClaimsLog, KeyValue, Records, AuthorInfo

logger = setup_logging(__file__, __name__)
RabbitMQWorker = GenericWorker.RabbitMQWorker

def purge_queues(queues):
    """
    Purges the queues on the RabbitMQ instance of its content

    :param queues: queue name that needs to be purged
    :return: no return
    """

    publish_worker = RabbitMQWorker()
    publish_worker.connect(app.config.get('RABBITMQ_URL'))

    for worker, wconfig in app.config.get('WORKERS').iteritems():
        for x in ('publish', 'subscribe'):
Esempio n. 2
0

import multiprocessing
import threading
import time
import signal
import sys
import os
from ADSOrcid import app
from ADSOrcid.pipeline import workers, GenericWorker
from ADSOrcid.utils import setup_logging
from copy import deepcopy
from threading import Thread


logger = setup_logging(os.path.abspath(os.path.join(__file__, '..')), __name__)


class Singleton(object):
    """
    Singleton type class. Collates a list of the class instances.
    """

    _instances = {}

    def __call__(cls, *args, **kwargs):
        if cls not in cls._instances:
            cls._instances[cls] = \
                super(Singleton, cls).__call__(*args, **kwargs)
        return cls._instances[cls]