https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

11/18/2019, 11:48 PM
if python code in an
@rule
throws an exception, how will the engine become aware of that?
a

aloof-angle-91616

11/18/2019, 11:50 PM
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

hundreds-breakfast-49010

11/18/2019, 11:50 PM
ok
the high level thing I'm trying to do here is make a rule that throws an exception not get memoized
a

aloof-angle-91616

11/18/2019, 11:50 PM
need to see what happens if it's not a coroutine
h

hundreds-breakfast-49010

11/18/2019, 11:51 PM
ah yeah I see where that
PyGeneratorResponse
is handled in the engine
a

aloof-angle-91616

11/18/2019, 11:51 PM
extern_generator_send()
is in
native.py
ok, it's in
<http://nodes.rs|nodes.rs>
still
h

hundreds-breakfast-49010

11/18/2019, 11:52 PM
the
Handle
in
PyGeneratorResponse::Throw(Handle)
is the python exception object, right?
a

aloof-angle-91616

11/18/2019, 11:52 PM
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

hundreds-breakfast-49010

11/18/2019, 11:53 PM
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

hundreds-breakfast-49010

11/18/2019, 11:54 PM
that makes sense to me
a

aloof-angle-91616

11/18/2019, 11:54 PM
HYPE
h

hundreds-breakfast-49010

11/18/2019, 11:55 PM
so an exception is just one way the
Task::run()
NodeFuture
can fail
a

aloof-angle-91616

11/18/2019, 11:55 PM
hm
yes, but it's also the most likely reason i think
that's just intuition
h

hundreds-breakfast-49010

11/18/2019, 11:56 PM
sure
a

aloof-angle-91616

11/18/2019, 11:56 PM
i would also want other failures to not be cached too i think
(meetings for an hour)
h

hundreds-breakfast-49010

11/18/2019, 11:56 PM
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

aloof-angle-91616

11/18/2019, 11:58 PM
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

hundreds-breakfast-49010

11/18/2019, 11:58 PM
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

aloof-angle-91616

11/18/2019, 11:58 PM
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