Преглед изворни кода

Raise exception when client hangs up.

Jelmer Vernooij пре 16 година
родитељ
комит
d2d9e28d11
2 измењених фајлова са 14 додато и 1 уклоњено
  1. 11 0
      dulwich/errors.py
  2. 3 1
      dulwich/protocol.py

+ 11 - 0
dulwich/errors.py

@@ -70,3 +70,14 @@ class NotGitRepository(Exception):
 
     def __init__(self, *args, **kwargs):
         Exception.__init__(self, *args, **kwargs)
+
+
+class GitProtocolError(Exception):
+    """Git protocol exception."""
+    
+    def __init__(self, *args, **kwargs):
+        Exception.__init__(self, *args, **kwargs)
+
+
+class HangupException(GitProtocolError):
+    """Hangup exception."""

+ 3 - 1
dulwich/protocol.py

@@ -17,6 +17,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+from errors import HangupException
+
 TCP_GIT_PORT = 9418
 
 class ProtocolFile(object):
@@ -50,7 +52,7 @@ class Protocol(object):
         """
         sizestr = self.read(4)
         if not sizestr:
-            return None
+            raise HangupException()
         size = int(sizestr, 16)
         if size == 0:
             return None