[pypy-svn] pypy fast-forward: check for signals in sendall(). test_sendall_interrupted now passes!

amauryfa commits-noreply at bitbucket.org
Tue Jan 11 22:41:26 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40599:2ef5059d91b0
Date: 2011-01-11 21:13 +0100
http://bitbucket.org/pypy/pypy/changeset/2ef5059d91b0/

Log:	check for signals in sendall(). test_sendall_interrupted now passes!

diff --git a/pypy/rlib/rsocket.py b/pypy/rlib/rsocket.py
--- a/pypy/rlib/rsocket.py
+++ b/pypy/rlib/rsocket.py
@@ -1001,7 +1001,7 @@
         finally:
             rffi.free_nonmovingbuffer(data, dataptr)
 
-    def sendall(self, data, flags=0):
+    def sendall(self, data, flags=0, signal_checker=None):
         """Send a data string to the socket.  For the optional flags
         argument, see the Unix manual.  This calls send() repeatedly
         until all data is sent.  If an error occurs, it's impossible
@@ -1014,6 +1014,8 @@
                 res = self.send_raw(p, remaining, flags)
                 p = rffi.ptradd(p, res)
                 remaining -= res
+                if signal_checker:
+                    signal_checker.check()
         finally:
             rffi.free_nonmovingbuffer(data, dataptr)
 

diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -10,6 +10,13 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter import gateway
 
+class SignalChecker:
+    def __init__(self, space):
+        self.space = space
+
+    def check(self):
+        self.space.getexecutioncontext().checksignals()
+
 class W_RSocket(Wrappable, RSocket):
     def __del__(self):
         self.clear_all_weakrefs()
@@ -234,7 +241,7 @@
         to tell how much data has been sent.
         """
         try:
-            count = self.sendall(data, flags)
+            count = self.sendall(data, flags, SignalChecker(space))
         except SocketError, e:
             raise converted_error(space, e)
     sendall_w.unwrap_spec = ['self', ObjSpace, 'bufferstr', int]


More information about the Pypy-commit mailing list