コード例 #1
0
    def do_send_string(self, space, buffer, offset, size):
        from pypy.module._multiprocessing.interp_win32 import _WriteFile, ERROR_NO_SYSTEM_RESOURCES
        from pypy.rlib import rwin32

        charp = rffi.str2charp(buffer)
        written_ptr = lltype.malloc(rffi.CArrayPtr(rwin32.DWORD).TO, 1, flavor="raw")
        try:
            result = _WriteFile(self.handle, rffi.ptradd(charp, offset), size, written_ptr, rffi.NULL)

            if result == 0 and rwin32.GetLastError() == ERROR_NO_SYSTEM_RESOURCES:
                raise operationerrfmt(space.w_ValueError, "Cannot send %d bytes over connection", size)
        finally:
            rffi.free_charp(charp)
            lltype.free(written_ptr, flavor="raw")
コード例 #2
0
    def do_send_string(self, space, buf, offset, size):
        from pypy.module._multiprocessing.interp_win32 import (
            _WriteFile, ERROR_NO_SYSTEM_RESOURCES)
        from rpython.rlib import rwin32

        with rffi.scoped_view_charp(buf) as charp:
            written_ptr = lltype.malloc(rffi.CArrayPtr(rwin32.DWORD).TO,
                                        1,
                                        flavor='raw')
            try:
                result = _WriteFile(self.handle, rffi.ptradd(charp, offset),
                                    size, written_ptr, rffi.NULL)

                if (result == 0 and rwin32.GetLastError_saved()
                        == ERROR_NO_SYSTEM_RESOURCES):
                    raise oefmt(space.w_ValueError,
                                "Cannot send %d bytes over connection", size)
            finally:
                lltype.free(written_ptr, flavor='raw')
コード例 #3
0
ファイル: interp_connection.py プロジェクト: mozillazg/pypy
    def do_send_string(self, space, buf, offset, size):
        from pypy.module._multiprocessing.interp_win32 import (
            _WriteFile, ERROR_NO_SYSTEM_RESOURCES)
        from rpython.rlib import rwin32

        with rffi.scoped_view_charp(buf) as charp:
            written_ptr = lltype.malloc(rffi.CArrayPtr(rwin32.DWORD).TO, 1,
                                        flavor='raw')
            try:
                result = _WriteFile(
                    self.handle, rffi.ptradd(charp, offset),
                    size, written_ptr, rffi.NULL)

                if (result == 0 and
                    rwin32.GetLastError_saved() == ERROR_NO_SYSTEM_RESOURCES):
                    raise oefmt(space.w_ValueError,
                                "Cannot send %d bytes over connection", size)
            finally:
                lltype.free(written_ptr, flavor='raw')