Skip to content

Commit 21276ff

Browse files
Allow dpctl.SyclEventRaw.wait to take a sequence of events
1 parent 1ed961d commit 21276ff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

dpctl/_sycl_event.pyx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import logging
2525

2626
from cpython cimport pycapsule
2727
from libc.stdint cimport uint64_t
28+
import collections.abc
2829

2930
from ._backend cimport ( # noqa: E211
3031
DPCTLEvent_Copy,
@@ -199,14 +200,19 @@ cdef class SyclEventRaw(_SyclEventRaw):
199200

200201
@staticmethod
201202
def wait(event):
202-
if isinstance(event, list):
203+
""" Waits for a given event or a sequence of events.
204+
"""
205+
if (isinstance(event, collections.abc.Sequence) and
206+
all( (isinstance(el, SyclEventRaw) for el in event) )):
203207
for e in event:
204208
SyclEventRaw._wait(e)
205209
elif isinstance(event, SyclEventRaw):
206210
SyclEventRaw._wait(event)
207211
else:
208-
raise ValueError("The passed argument is not a list \
209-
or a SyclEventRaw type.")
212+
raise TypeError(
213+
"The passed argument is not a SyclEventRaw type or "
214+
"a sequence of such objects"
215+
)
210216

211217
def addressof_ref(self):
212218
""" Returns the address of the C API `DPCTLSyclEventRef` pointer as

0 commit comments

Comments
 (0)