def test_start(self):
        """
        test datastream worker pool
        """
        s = SocketSession(ip='x')
        s.keywords = ['google', 'bieber']
        s.save()

        w = WorkerPool()
        w.start()
        time.sleep(1)
        w.terminate()

        self.assertGreater(RawStreamQueue.objects.count(), 0)
    def test_start(self):
        """
        test datastream worker pool
        """
        s = SocketSession(ip='x')
        s.keywords = ['google', 'bieber']
        s.save()

        w = WorkerPool()
        w.start()
        while not RawStreamQueue.objects.count():
            time.sleep(0.1)

        w.terminate()

        self.assertGreater(RawStreamQueue.objects.count(), 0)
Example #3
0
import time
import logging

from smm.datastream.workerPool import WorkerPool
from smm import models


logger = logging.getLogger('start-collector')


#connect to db
models.connect()

s = models.SocketSession()
s.ip='x'
s.keywords = ['google']
s.save()

# init pool
pool = WorkerPool()

try:

    pool.start()
    logger.info("started WorkerPool with size %s", len(pool.pool))
    while True:
        time.sleep(60)
        logging.info('RawStreamQueue size: %s', models.RawStreamQueue.objects.count())

except (KeyboardInterrupt, SystemExit):
    pool.terminate()
import time
import logging

from smm.datastream.workerPool import WorkerPool
from smm import models


logger = logging.getLogger('start-collector')


#connect to db
models.connect()

# init pool
pool = WorkerPool()

try:

    pool.start()
    logger.info("started WorkerPool with size %s", len(pool.pool))
    while True:
        time.sleep(60)
        logging.info('RawStreamQueue size: %s', models.RawStreamQueue.objects.count())

except (KeyboardInterrupt, SystemExit):
    pool.terminate()