if python code in an `@rule` throws an exception, ...
# development
h
if python code in an
@rule
throws an exception, how will the engine become aware of that?
a
if it's a generator method (uses
yield
) and it raises an exception,
extern_generator_send()
will capture it in
except Exception as e
that gets sent back to the engine as a
PyGeneratorResponse::Throw
h
ok
the high level thing I'm trying to do here is make a rule that throws an exception not get memoized
a
need to see what happens if it's not a coroutine
h
ah yeah I see where that
PyGeneratorResponse
is handled in the engine
a
extern_generator_send()
is in
native.py
ok, it's in
<http://nodes.rs|nodes.rs>
still
h
the
Handle
in
PyGeneratorResponse::Throw(Handle)
is the python exception object, right?
a
yes
look at
native.py
to see how it's constructed
the mapping between cbindgen rust enums and cffi is very cool but not obvious
h
I think that makes sense to me even though I haven't fully traced it
okay so if an
@rule
throws an exception, that means that
generator_send
returns an
Err
^that's where the engine checks whether invoking the
@rule
function produces a value or a generator
and the
generator_send()
Err i think propagates into the
Task::run() -> NodeFuture<Value>
result
h
that makes sense to me
a
HYPE
h
so an exception is just one way the
Task::run()
NodeFuture
can fail
a
hm
yes, but it's also the most likely reason i think
that's just intuition
h
sure
a
i would also want other failures to not be cached too i think
(meetings for an hour)
h
that makes sense yeah
it makes sense that most failures in practice would be exceptions in python, I just don't have an exhaustive list in my head of other places a future failure could come from
intrinsics could do it too I"m sure
a
i'm fine with the rule of thumb being don't cache any failures here
and then if there are other failures we want to cache we can wrap them and make them not errors or something
h
does it make sense to you that the place in the code to change this would be somewhere in
complete
on
graph/src/lib.rs
or
graph/src/entry.rs
?
a
30 seconds
yes
especially the
pub(crate) fn clear()
seems like the right method to use here
please feel free to add more enums/etc to represent states of nodes being computed if the current model isn't broad enough