Skip to content

Commit 414517e

Browse files
committed
Fix Buffer.mapAsync
Recent optimizations skip waiting for a return value if the Function was annotated with None as return type. In Buffer.mapAsync we still need to wait for the mapping to be complete, thus change the return value to some Dummy class type.
1 parent 149fd66 commit 414517e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

webgpu/webgpu_api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,14 @@ async def requestDevice(
11011101
return Device(device)
11021102

11031103

1104+
class _DummyNone:
1105+
pass
1106+
1107+
11041108
class Buffer(BaseWebGPUHandle):
1105-
async def mapAsync(self, mode: MapMode, offset: int = 0, size: int = 0) -> None:
1109+
async def mapAsync(
1110+
self, mode: MapMode, offset: int = 0, size: int = 0
1111+
) -> _DummyNone: # don't return None, as this would ignore the blocking wait
11061112
return await self.handle.mapAsync(mode, offset, size)
11071113

11081114
def getMappedRange(self, offset: int = 0, size: int = 0) -> int:

0 commit comments

Comments
 (0)