def wakeUp(self): """Send a byte to my connection. """ try: util.untilConcludes(self.w.send, 'x') except socket.error, (err, msg): if err != errno.WSAEWOULDBLOCK: raise
def emit(self, eventDict): text = textFromEventDict(eventDict) if text is None: return timeStr = self.formatTime(eventDict['time']) fmtDict = {'system': eventDict['system'], 'text': text.replace("\n", "\n\t")} msgStr = _safeFormat("[%(system)s] %(text)s\n", fmtDict) util.untilConcludes(self.write, timeStr + " " + msgStr) util.untilConcludes(self.flush) # Hoorj!
def wakeUp(self): """Write one byte to the pipe, and flush it. """ # We don't use fdesc.writeToFD since we need to distinguish # between EINTR (try again) and EAGAIN (do nothing). if self.o is not None: try: util.untilConcludes(os.write, self.o, 'x') except OSError, e: # XXX There is no unit test for raising the exception # for other errnos. See #4285. if e.errno != errno.EAGAIN: raise
def testUninterruptably(self): def f(a, b): self.calls += 1 exc = self.exceptions.pop() if exc is not None: raise exc(errno.EINTR, "Interrupted system call!") return a + b self.exceptions = [None] self.calls = 0 self.assertEquals(util.untilConcludes(f, 1, 2), 3) self.assertEquals(self.calls, 1) self.exceptions = [None, OSError, IOError] self.calls = 0 self.assertEquals(util.untilConcludes(f, 2, 3), 5) self.assertEquals(self.calls, 3)