Python pymongo.errors.ExceededMaxWaiters() Examples

The following are 6 code examples of pymongo.errors.ExceededMaxWaiters(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pymongo.errors , or try the search function .
Example #1
Source File: thread_util.py    From recruit with Apache License 2.0 5 votes vote down vote up
def acquire(self, blocking=True, timeout=None):
        if not self.waiter_semaphore.acquire(False):
            raise ExceededMaxWaiters()
        try:
            return self.semaphore.acquire(blocking, timeout)
        finally:
            self.waiter_semaphore.release() 
Example #2
Source File: thread_util.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def acquire(self, blocking=True, timeout=None):
        if not self.waiter_semaphore.acquire(False):
            raise ExceededMaxWaiters()
        try:
            return self.semaphore.acquire(blocking, timeout)
        finally:
            self.waiter_semaphore.release() 
Example #3
Source File: thread_util.py    From satori with Apache License 2.0 5 votes vote down vote up
def acquire(self, blocking=True, timeout=None):
        if not self.waiter_semaphore.acquire(False):
            raise ExceededMaxWaiters()
        try:
            return self.semaphore.acquire(blocking, timeout)
        finally:
            self.waiter_semaphore.release() 
Example #4
Source File: thread_util.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def acquire(self, blocking=True, timeout=None):
        if not self.waiter_semaphore.acquire(False):
            raise ExceededMaxWaiters()
        try:
            return self.semaphore.acquire(blocking, timeout)
        finally:
            self.waiter_semaphore.release() 
Example #5
Source File: thread_util.py    From opsbro with MIT License 5 votes vote down vote up
def acquire(self, blocking=True, timeout=None):
        if not self.waiter_semaphore.acquire(False):
            raise ExceededMaxWaiters()
        try:
            return self.semaphore.acquire(blocking, timeout)
        finally:
            self.waiter_semaphore.release() 
Example #6
Source File: TailThread.py    From mongodb_consistent_backup with Apache License 2.0 4 votes vote down vote up
def run(self):
        try:
            logging.info("Tailing oplog on %s for changes" % self.uri)
            self.timer.start(self.timer_name)

            self.state.set('running', True)
            self.connect()
            oplog = self.oplog()
            while not self.tail_stop.is_set() and not self.backup_stop.is_set():
                try:
                    self._cursor = self.db.get_oplog_cursor_since(self.__class__, self.last_ts)
                    while self.check_cursor():
                        try:
                            # get the next oplog doc and write it
                            doc = self._cursor.next()
                            if self.last_ts and self.last_ts >= doc['ts']:
                                continue
                            oplog.add(doc)

                            # update states
                            self.count  += 1
                            self.last_ts = doc['ts']
                            if self.first_ts is None:
                                self.first_ts = self.last_ts
                            update = {
                                'count':    self.count,
                                'first_ts': self.first_ts,
                                'last_ts':  self.last_ts
                            }
                            self.state.set(None, update, True)

                            # print status report every N seconds
                            self.status()
                        except NotMasterError:
                            # pymongo.errors.NotMasterError means a RECOVERING-state when connected to secondary (which should be true)
                            self.backup_stop.set()
                            logging.error("Node %s is in RECOVERING state! Stopping tailer thread" % self.uri)
                            raise OperationError("Node %s is in RECOVERING state! Stopping tailer thread" % self.uri)
                        except CursorNotFound:
                            self.backup_stop.set()
                            logging.error("Cursor disappeared on server %s! Stopping tailer thread" % self.uri)
                            raise OperationError("Cursor disappeared on server %s! Stopping tailer thread" % self.uri)
                        except (AutoReconnect, ConnectionFailure, ExceededMaxWaiters, ExecutionTimeout, NetworkTimeout), e:
                            logging.error("Tailer %s received %s exception: %s. Attempting retry" % (self.uri, type(e).__name__, e))
                            if self._tail_retry > self._tail_retry_max:
                                self.backup_stop.set()
                                logging.error("Reconnected to %s %i/%i times, stopping backup!" % (self.uri, self._tail_retry, self._tail_retry_max))
                                raise OperationError("Reconnected to %s %i/%i times, stopping backup!" % (self.uri, self._tail_retry, self._tail_retry_max))
                            self._tail_retry += 1
                        except StopIteration:
                            continue
                    sleep(1)
                finally:
                    if self._cursor:
                        logging.debug("Stopping oplog cursor on %s" % self.uri)
                        self._cursor.close()