def run(self):
        connection = self.server.create_connection()
        try:
            while True:
                if self.stop:
                    connection.quit()
                    return

                segment = None
                q       = None

                if self.server.conf.get("backup", False):
                    # Backup server - only check for segments that have been
                    # explcitly passed to us
                    try:
                        segment = self.server.segments.get(True, 1)
                        q       = self.server.segments
                    except:
                        pass

                else:
                    # Try to get a segment from the server's segment queue
                    try:
                        segment = self.server.segments.get(False)
                        q       = self.server.segments
                    except:
                        # Try to grab a segment from the global queue
                        segment = self.segments.get(False)
                        q       = self.segments

                if not segment:
                    continue

                try:
                    self.server.check_segment(connection, segment, self.segments, self.missing)
                except ConnectionClosedException, e:
                    connection = self.server.create_connection()
                except Exception, e:
                    log.error(e % "Unknown error: %s")

                if q:
                    q.task_done()

        except Exception, e:
            try:
                connection.quit()
            except:
                pass
dataset/ETHPy150Open wnielson/nzbverify/nzbverify/thread.py/SegmentCheckerThread.run/swapped operands of `%`