litegraph.js icon indicating copy to clipboard operation
litegraph.js copied to clipboard

asynchrone node

Open ramamama opened this issue 4 years ago • 5 comments

Hi, Great Job, I just have a question : Do you have a node sample with asynchrone function like axios ? rama

ramamama avatar Aug 26 '20 14:08 ramamama

you can use the Events system to trigger nodes once you end an async task but then you won't be able to take advantage of the nodes pool as all the nodes assume sync execution.

It could be possible to create a way to stop graph execution until a node trigger a signal and resume afterwards but thats a use-case I never explored and it will imply refactoring some code.

jagenjo avatar Aug 26 '20 15:08 jagenjo

thanks to your answer

ramamama avatar Aug 27 '20 09:08 ramamama

just an idea, i could be wrong, it seems each node's code is executed on a loop frame way, and with a nodeParentOnExecute( nodeChildOnExecute( ) ) logic.

what do you think about having a property like a "processed_at" timestamp or random hash in each node, refreshed each time the node is considered executed, propagated to the descendants, and execute each node's code ONCE and ONLY if :

  • node is added to the graph
  • or when a node parent : ------"processed_at" timestamp change ------is added/removed

this will avoid recomputing same already computed inputs + allow sync/async chaining without losing the usefull visual node chaining (without events i guess)

in all cases, good job for this lib

LAGENCECREE avatar Dec 04 '20 16:12 LAGENCECREE

it is an interesting idea, I will consider it in a future update.

jagenjo avatar Dec 04 '20 17:12 jagenjo

great ! im looking on my side a workaround for :

  • async onExecute (done, modifyng a litlle the transpiled js version)
  • time locking unecesary executions (i'm investigating)

LAGENCECREE avatar Dec 04 '20 18:12 LAGENCECREE