Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove assertion.
Browse files Browse the repository at this point in the history
fyellin committed Nov 2, 2024
1 parent c733c5f commit f8a71e6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions wgpu/backends/wgpu_native/_helpers.py
Original file line number Diff line number Diff line change
@@ -230,10 +230,13 @@ def to_camel_case(name):


class WgpuAwaitable:
"""An object that can be waited for, either synchronously using sync_wait() or asynchronously using await.
"""
Create an object representing the result of a wgpu call that requires a callback
to complete. The code can then call "awaitable.wait_sync()" to wait for the result
synchronously, or "await awaitable.wait_async()" to perform an asynchronous wait.
The purpose of this class is to implement the asynchronous methods in a
truly async manner, as well as to support a synchronous version of them.
The callback should call "awaitable.set_result()" when it has a result, or
"awaitable.set_error()" when it encounters an error.
"""

def __init__(self, title, callback, finalizer, poll_function=None, timeout=5.0):
@@ -255,7 +258,8 @@ def set_error(self, error):

def wait_sync(self):
if not self.poll_function:
# The result must come back without any polling.
if not self.event.is_set():
raise RuntimeError("Expected callback to have already happened")
assert self.event.is_set()
else:
maxtime = time.perf_counter() + float(self.timeout)
@@ -268,7 +272,8 @@ def wait_sync(self):

async def wait_async(self):
if not self.poll_function:
# The result must come back with the original function call.
if not self.event.is_set():
raise RuntimeError("Expected callback to have already happened")
assert self.event.is_set()
else:
maxtime = time.perf_counter() + float(self.timeout)

0 comments on commit f8a71e6

Please sign in to comment.