[pypy-svn] r77264 - pypy/branch/fast-forward/pypy/module/_multiprocessing
afa at codespeak.net
afa at codespeak.net
Wed Sep 22 12:58:38 CEST 2010
Author: afa
Date: Wed Sep 22 12:58:36 2010
New Revision: 77264
Modified:
pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py
pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py
Log:
Fix translation of _multiprocessing module on Windows
Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py (original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_connection.py Wed Sep 22 12:58:36 2010
@@ -3,7 +3,7 @@
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import (
OperationError, wrap_oserror, operationerrfmt)
-from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.rpython.lltypesystem import rffi, lltype, llmemory
from pypy.rlib.rarithmetic import intmask
import sys, os
@@ -348,15 +348,16 @@
rwin32.GetLastError() == ERROR_NO_SYSTEM_RESOURCES):
raise operationerrfmt(
space.w_ValueError,
- "Cannot send %ld bytes over connection", size)
+ "Cannot send %d bytes over connection", size)
finally:
rffi.free_charp(charp)
lltype.free(written_ptr, flavor='raw')
def do_recv_string(self, space, maxlength):
from pypy.module._multiprocessing.interp_win32 import (
- _ReadFile)
+ _ReadFile, _PeekNamedPipe, ERROR_BROKEN_PIPE, ERROR_MORE_DATA)
from pypy.rlib import rwin32
+ from pypy.interpreter.error import wrap_windowserror
read_ptr = lltype.malloc(rffi.CArrayPtr(rwin32.DWORD).TO, 1,
flavor='raw')
@@ -371,31 +372,34 @@
err = rwin32.GetLastError()
if err == ERROR_BROKEN_PIPE:
- return MP_END_OF_FILE
+ return MP_END_OF_FILE, lltype.nullptr(rffi.CCHARP.TO)
elif err != ERROR_MORE_DATA:
- return MP_STANDARD_ERROR
+ raise wrap_windowserror(space, WindowsError(err, "_ReadFile"))
# More data...
if not _PeekNamedPipe(self.handle, rffi.NULL, 0,
- rffi.NULL, rffi.NULL, left_ptr):
- return MP_STANDARD_ERROR
+ lltype.nullptr(rwin32.LPDWORD.TO),
+ lltype.nullptr(rwin32.LPDWORD.TO),
+ left_ptr):
+ raise wrap_windowserror(space, rwin32.lastWindowsError())
- length = read_ptr[0] + left_ptr[0]
+ length = intmask(read_ptr[0] + left_ptr[0])
if length > maxlength:
return MP_BAD_MESSAGE_LENGTH, lltype.nullptr(rffi.CCHARP.TO)
newbuf = lltype.malloc(rffi.CCHARP.TO, length + 1, flavor='raw')
- raw_memcopy(self.buffer, newbuf, read_ptr[0])
+ for i in range(read_ptr[0]):
+ newbuf[i] = self.buffer[i]
result = _ReadFile(self.handle,
rffi.ptradd(newbuf, read_ptr[0]), left_ptr[0],
read_ptr, rffi.NULL)
- if result:
- assert read_ptr[0] == left_ptr[0]
- return length, newbuf
- else:
+ if not result:
rffi.free_charp(newbuf)
- return MP_STANDARD_ERROR, lltype.nullptr(rffi.CCHARP.TO)
+ raise wrap_windowserror(space, rwin32.lastWindowsError())
+
+ assert read_ptr[0] == left_ptr[0]
+ return length, newbuf
finally:
lltype.free(read_ptr, flavor='raw')
Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py (original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py Wed Sep 22 12:58:36 2010
@@ -1,6 +1,6 @@
from pypy.interpreter.gateway import ObjSpace, W_Root, unwrap_spec, interp2app
from pypy.interpreter.function import StaticMethod
-from pypy.interpreter.error import wrap_windowserror
+from pypy.interpreter.error import wrap_windowserror, OperationError
from pypy.rlib import rwin32
from pypy.rlib.rarithmetic import r_uint
from pypy.rpython.lltypesystem import rffi, lltype
@@ -14,7 +14,7 @@
PIPE_UNLIMITED_INSTANCES
NMPWAIT_WAIT_FOREVER
ERROR_PIPE_CONNECTED ERROR_SEM_TIMEOUT ERROR_PIPE_BUSY
- ERROR_NO_SYSTEM_RESOURCES
+ ERROR_NO_SYSTEM_RESOURCES ERROR_BROKEN_PIPE ERROR_MORE_DATA
""".split()
class CConfig:
@@ -51,6 +51,14 @@
rwin32.LPDWORD, rwin32.LPDWORD, rwin32.LPDWORD],
rwin32.BOOL)
+_PeekNamedPipe = rwin32.winexternal(
+ 'PeekNamedPipe', [
+ rwin32.HANDLE,
+ rffi.VOIDP,
+ rwin32.DWORD,
+ rwin32.LPDWORD, rwin32.LPDWORD, rwin32.LPDWORD],
+ rwin32.BOOL)
+
_CreateFile = rwin32.winexternal(
'CreateFileA', [
rwin32.LPCSTR,
@@ -81,7 +89,7 @@
raise wrap_windowserror(space, rwin32.lastWindowsError())
def GetLastError(space):
- return space.wrap(rwin32.lastWindowsError())
+ return space.wrap(rwin32.GetLastError())
@unwrap_spec(ObjSpace, str, r_uint, r_uint, r_uint, r_uint, r_uint, r_uint, W_Root)
def CreateNamedPipe(space, name, openmode, pipemode, maxinstances,
More information about the Pypy-commit
mailing list