RFC: Add Script Startup Priorities

Offen
#621 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
lua
Bereich
tooling

Rechercherichtung

Beginne damit, den Start-Scan von script_manager und den Metadatenblock nachzuverfolgen, der gelesen wird, bevor die Skripte starten. Lege fest, wie Prioritäten, einschließlich des reservierten Bereichs für Systemskripte, den Start und die Reihenfolge der Ereignisregistrierung beeinflussen sollen; die Arbeit ist abgeschlossen, wenn das Verhalten und der Umgang mit widersprüchlichen oder fehlenden Prioritäten spezifiziert und implementiert sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Lua
Sterne
219
Forks
142
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus darktable-org/lua-scripts

Alle Issues in darktable-org/lua-scripts

Ähnliche Issues

Weitere Issues zu Lua

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.