darktable-org / darktable-org/lua-scripts

RFC: Add Script Startup Priorities

Aperta
#621 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lua
Stelle
219
Fork
142
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Current script startup order

If scripts are started from a luarc file, then they start in the order they are listed in.

If script_manager is handling startup then it works like this:

  • script manager searches the lua directory for scripts and sorts them alphabetically
  • any lua file in a lib directory is ignored.
  • script_manager ignores itself and doesn't try to start a second copy
  • for each script that's found a check to see if it was running at darktable shutdown is made and if it was running it's started
Why does it matter?

Most lua-scripts rely on events to trigger actions. As each script starts it registers events and they are placed in a table for each event type. When an event is triggered the event is sent to the first script that registered, the script performs it's actions, the event is sent to the second script that registered, etc...

Most of the time the order scripts receive events in is not important. However, sometimes order is important. For instance:

  • Lua has an event called inter-script-communication
  • It can be used for cooperative multi tasking so that a long running script, such as cache generation, doesn't block the rest of the lua-scripts until it completes.
  • In the case of cooperative multitasking, the scheduler task should start first so that it doesn't have to wait for for each script to look at the event before getting to the scheduler. Or if I'm debugging the communications, then I would want the debugging script to start first so that it could show the communication before the action takes place.
Possible solutions
  • Dependencies - This was my first thought, but I think this would be a nightmare from building a dependency tree to ending up with circular dependencies.
  • Priorities - Much easier to implement. Much less prone to error. Dependencies probably offer finer control, but I'm not sure it's necessary.
Implementation

We already have a metadata block that is read before starting the script, so that would be the easiest, cleanest solution. A certain block of priorities should be reserved for "system"scripts such as scheduler.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando la scansione di avvio di script_manager e il blocco di metadati che viene letto prima dell’avvio degli script. Definisci in che modo le priorità, compreso l’intervallo riservato agli script di sistema, debbano influire sull’avvio e sull’ordine di registrazione degli eventi; il lavoro è completato quando il comportamento e la gestione delle priorità in conflitto o mancanti sono specificati e implementati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.