/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Andrew Bennetts
  • Date: 2009-01-07 00:58:30 UTC
  • mto: This revision was merged to the branch mainline in revision 3935.
  • Revision ID: andrew.bennetts@canonical.com-20090107005830-ua1dmtrnyl37acf4
Quick attempt at adding some EINTR-proofing to smart protocol code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1549
1549
    """
1550
1550
    b = ''
1551
1551
    while len(b) < bytes:
1552
 
        new = socket.recv(bytes - len(b))
 
1552
        new = until_no_eintr(socket.recv, bytes - len(b))
1553
1553
        if new == '':
1554
1554
            break # eof
1555
1555
        b += new
1564
1564
    """
1565
1565
    chunk_size = 2**16
1566
1566
    for pos in xrange(0, len(bytes), chunk_size):
1567
 
        socket.sendall(bytes[pos:pos+chunk_size])
 
1567
        until_no_eintr(socket.sendall, bytes[pos:pos+chunk_size])
1568
1568
 
1569
1569
 
1570
1570
def dereference_path(path):
1637
1637
            raise errors.NoSuchFile(f)
1638
1638
        raise
1639
1639
 
 
1640
 
 
1641
def until_no_eintr(f, *a, **kw):
 
1642
    # Borrowed from Twisted's twisted.python.util.untilConcludes function.
 
1643
    while True:
 
1644
        try:
 
1645
            return f(*a, **kw)
 
1646
        except (IOError, OSError), e:
 
1647
            if e.args[0] == errno.EINTR:
 
1648
                continue
 
1649
            raise
 
1650
 
 
1651
 
1640
1652
if sys.platform == "win32":
1641
1653
    import msvcrt
1642
1654
    def getchar():