Example #1
0
  def run(self):
    while not self.stopped:
      wakeup = None
      for sel in self.selectables.copy():
        t = self._update(sel)
        if t is not None:
          if wakeup is None:
            wakeup = t
          else:
            wakeup = min(wakeup, t)

      if wakeup is None:
        timeout = None
      else:
        timeout = max(0, wakeup - time.time())

      rd, wr, ex = select(self.reading, self.writing, (), timeout)

      for sel in wr:
        if sel.writing():
          sel.writeable()

      for sel in rd:
        if sel.reading():
          sel.readable()

      now = time.time()
      for sel in self.selectables.copy():
        w = sel.timing()
        if w is not None and now > w:
          sel.timeout()
Example #2
0
  def run(self):
    try:
      while not self.stopped:
        wakeup = None
        for sel in self.selectables.copy():
          t = self._update(sel)
          if t is not None:
            if wakeup is None:
              wakeup = t
            else:
              wakeup = min(wakeup, t)

        rd = []
        wr = []
        ex = []

        while True:
          try:
            if wakeup is None:
              timeout = None
            else:
              timeout = max(0, wakeup - time.time())
            rd, wr, ex = select(self.reading, self.writing, (), timeout)
            break
          except SelectError, e:
            # Repeat the select call if we were interrupted.
            if e[0] == errno.EINTR:
              continue
            else:
              # unrecoverable: promote to outer try block
              raise

        for sel in wr:
          if sel.writing():
            sel.writeable()

        for sel in rd:
          if sel.reading():
            sel.readable()

        now = time.time()
        for sel in self.selectables.copy():
          w = sel.timing()
          if w is not None and now > w:
            sel.timeout()
    except Exception, e:
      self.exception = e
      info = format_exc()
      log.error("qpid.messaging I/O thread has died: %s" % str(e))
      for sel in self.selectables.copy():
        if hasattr(sel, "abort"):
          sel.abort(e, info)
      raise
Example #3
0
    def run(self):
        while not self.stopped:
            wakeup = None
            for sel in self.selectables.copy():
                t = self._update(sel)
                if t is not None:
                    if wakeup is None:
                        wakeup = t
                    else:
                        wakeup = min(wakeup, t)

            rd = []
            wr = []
            ex = []

            while True:
                try:
                    if wakeup is None:
                        timeout = None
                    else:
                        timeout = max(0, wakeup - time.time())
                    rd, wr, ex = select(self.reading, self.writing, (),
                                        timeout)
                    break
                except Exception, (err, strerror):
                    # Repeat the select call if we were interrupted.
                    if err == errno.EINTR:
                        continue
                    else:
                        raise

            for sel in wr:
                if sel.writing():
                    sel.writeable()

            for sel in rd:
                if sel.reading():
                    sel.readable()

            now = time.time()
            for sel in self.selectables.copy():
                w = sel.timing()
                if w is not None and now > w:
                    sel.timeout()
Example #4
0
  def run(self):
    while not self.stopped:
      wakeup = None
      for sel in self.selectables.copy():
        t = self._update(sel)
        if t is not None:
          if wakeup is None:
            wakeup = t
          else:
            wakeup = min(wakeup, t)

      rd = []
      wr = []
      ex = []

      while True:
        try:
          if wakeup is None:
            timeout = None
          else:
            timeout = max(0, wakeup - time.time())
          rd, wr, ex = select(self.reading, self.writing, (), timeout)
          break
        except Exception, (err, strerror):
          # Repeat the select call if we were interrupted.
          if err == errno.EINTR:
            continue
          else:
            raise

      for sel in wr:
        if sel.writing():
          sel.writeable()

      for sel in rd:
        if sel.reading():
          sel.readable()

      now = time.time()
      for sel in self.selectables.copy():
        w = sel.timing()
        if w is not None and now > w:
          sel.timeout()