Exemplo n.º 1
0
def thread(thread_count):
    """validate threads"""
    try:
        int(thread_count)
    except:
        raise ValueError(thread_count + "is not an integer")
    if int(thread_count) > settings.threads():
        raise ValueError("you have exceeded the thread limitation")
Exemplo n.º 2
0
def thread(thread_count):
    """validate threads"""
    try:
        int(thread_count)
    except:
        raise ValueError(thread_count + "is not an integer")
    if int(thread_count) > settings.threads():
        raise ValueError("you have exceeded the thread limitation")
Exemplo n.º 3
0
    def batch(self, date):
        """multiprocessing to get all the events"""

        batched = []
        mpool = multiprocessing.Pool(settings.threads(), self.utility.init_worker)
        paginations = list(range(1, settings.pagination_limit() + 1))
        per_page = str(settings.per_page())

        try:
            partial_get = partial(self.get, per_page, date)
            data = mpool.map(partial_get, paginations)
            for i in data:
                batched.extend(i["events"])
            return batched
        except KeyboardInterrupt:
            print "Caught KeyboardInterrupt, terminating workers"
            mpool.terminate()
            mpool.join()
Exemplo n.º 4
0
 def parse_threads(self):
     """determine threads"""
     if self.options['threads'] is None:
         return settings.threads()
     validate.thread(self.options["threads"])
     return self.options['threads']
Exemplo n.º 5
0
 def parse_threads(self):
     """determine threads"""
     if self.options['threads'] is None:
         return settings.threads()
     validate.thread(self.options["threads"])
     return self.options['threads']