Skip to content

Commit 9b060b8

Browse files
Allow dpctl.SyclEventRaw.wait to take a sequence of events
1 parent fe5f497 commit 9b060b8

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,
@@ -206,14 +207,19 @@ cdef class SyclEventRaw(_SyclEventRaw):
206207

207208
@staticmethod
208209
def wait(event):
209-
if isinstance(event, list):
210+
""" Waits for a given event or a sequence of events.
211+
"""
212+
if (isinstance(event, collections.abc.Sequence) and
213+
all( (isinstance(el, SyclEventRaw) for el in event) )):
210214
for e in event:
211215
SyclEventRaw._wait(e)
212216
elif isinstance(event, SyclEventRaw):
213217
SyclEventRaw._wait(event)
214218
else:
215-
raise ValueError("The passed argument is not a list \
216-
or a SyclEventRaw type.")
219+
raise TypeError(
220+
"The passed argument is not a SyclEventRaw type or "
221+
"a sequence of such objects"
222+
)
217223

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

0 commit comments

Comments
 (0)