Skip to content

Python Events API

Function Signature Notes
event_create () -> int
event_destroy (event: int) -> None Not allowed while a stream is waiting on it
event_record (event: int, stream: int = HA_STREAM_DEFAULT) -> None
event_synchronize (event: int) -> None Blocks
event_query (event: int) -> bool True when complete, False while not yet complete. Raises if never recorded or on a runtime error

Example

event_create

The event is created unrecorded. It marks nothing until event_record.

Example
1
2
3
import hart

done = hart.event_create()

event_destroy

Do not destroy an event that a stream is still waiting on.

Example
1
2
3
4
import hart

hart.event_synchronize(done)
hart.event_destroy(done)

event_query

Non-blocking poll. An incomplete event returns False rather than raising; an event that was never recorded raises RuntimeError (HaEventNotRecorded).

Example
1
2
3
4
5
import hart

hart.event_record(done, stream)
while not hart.event_query(done):  # True: the recorded point has been reached
    do_unrelated_host_work()

event_record

Only marks a point; recording itself waits for nothing.

Example
1
2
3
4
5
6
7
import hart

hart.launch_kernel_async_with_binary_path(first_path, args, stream)
hart.event_record(done, stream)  # marks the point right after this launch
hart.launch_kernel_async_with_binary_path(second_path, args2, stream)

hart.event_synchronize(done)  # returns after the first launch, not the second

event_synchronize

Waits for one point, not the whole pipeline.

Example
1
2
3
4
import hart

hart.event_record(done, stream)
hart.event_synchronize(done)  # raises if never recorded

See also