430 | | fout.write(data) |
431 | | fout.flush() |
432 | | |
433 | | if mask & (select.POLLHUP | select.POLLERR) : |
434 | | # Some pipe has no more datas so we don't |
435 | | # want to continue to poll this file |
436 | | toclose = None |
437 | | try : |
438 | | fobj = instreams[fd] |
439 | | if fobj["name"] == "stdin" : |
440 | | toclose = outstreams[fobj["out"]] |
441 | | self.logdebug("No more data to read from %s (POLLUP or POLLERR received)" % fobj["name"]) |
442 | | except KeyError : |
443 | | fobj = outstreams[fd] |
444 | | if fobj["name"] == "stderr" : |
445 | | toclose = instreams[fobj["in"]] |
446 | | self.logdebug("No more data to write to %s (POLLUP or POLLERR received)" % fobj["name"]) |
| 439 | try : |
| 440 | fout.write(data) |
| 441 | except IOError, msg : |
| 442 | self.logdebug("Interrupted Write : %s" % msg) |
| 443 | else : |
| 444 | try : |
| 445 | fout.flush() |
| 446 | except IOError, msg : |
| 447 | self.logdebug("Interrupted Flush : %s" % msg) |
| 448 | |
| 449 | if mask & (select.POLLHUP | select.POLLERR) : |
| 450 | # Some pipe has no more datas so we don't |
| 451 | # want to continue to poll this file |
| 452 | toclose = None |
| 453 | try : |
| 454 | fobj = instreams[fd] |
| 455 | if fobj["name"] == "stdin" : |
| 456 | toclose = outstreams[fobj["out"]] |
| 457 | self.logdebug("No more data to read from %s (POLLUP or POLLERR received)" % fobj["name"]) |
| 458 | except KeyError : |
| 459 | fobj = outstreams[fd] |
| 460 | if fobj["name"] == "stderr" : |
| 461 | toclose = instreams[fobj["in"]] |
| 462 | self.logdebug("No more data to write to %s (POLLUP or POLLERR received)" % fobj["name"]) |
| 463 | |
| 464 | if not fobj["done"] : |
| 465 | self.unregisterFileNo(pollster, fd) |
| 466 | fobj["done"] = 1 |
| 467 | if toclose is not None : |
| 468 | self.logdebug("Closing %s" % toclose["name"]) |
| 469 | try : |
| 470 | toclose["file"].close() |
| 471 | except : |
| 472 | self.logdebug("Interrupted Close") |
448 | | if not fobj["done"] : |
449 | | self.unregisterFileNo(pollster, fd) |
450 | | fobj["done"] = 1 |
451 | | if toclose is not None : |
452 | | self.logdebug("Closing %s" % toclose["name"]) |
453 | | toclose["file"].close() |
454 | | |
455 | | if mask & select.POLLNVAL : |
456 | | self.logdebug("CLOSED : %s" % self.formatFileEvent(fd, mask, instreams, outstreams)) |
457 | | |
458 | | except IOError, msg : |
459 | | self.logdebug("IOError : %s -- %s" % (msg, self.formatFileEvent(fd, mask, instreams, outstreams))) |
460 | | time.sleep(0.01) # give some time to the CPU |
461 | | except IOError, msg : |
462 | | self.logdebug("IOError : %s" % msg) |
463 | | time.sleep(0.01) # give some time to the CPU |
| 474 | if mask & select.POLLNVAL : |
| 475 | self.logdebug("CLOSED : %s" % self.formatFileEvent(fd, mask, instreams, outstreams)) |