Lightroom SDK: task termination upon shutdown / reload.

  • 3
  • Idea
  • Updated 8 years ago
Presently, all async tasks are left running even when reloading a plugin.

Thus, its possible to get a buildup of asynchronous tasks if care is not taken to shutdown appropriately.

I have solved this problem for myself by dividing sleep into 100ms increments and checking for shutdown flag after each increment (so a 5 second sleep is really 50 100msec sleeps).

And trying to remember to check a shutdown flag in every other instance where it matters.

Even with these safeguards, there is a "race" between shutdown and re-init, since shutting down the previous instance of the plugin is overlapped with the new instance coming up, and the new instance coming up can not check the status of the previous instance's shutdown other than by using a file or something, since they have different global environments.

A more elegant solution would be OK with me. For example, an option to have a task be automatically terminated (as soon as it yields or sleeps) upon shutdown. And maybe return a status from LrTasks.sleep, and/or an LrTasks.shutdown flag. - haven't thought this through really...

In any case, I'd like to see the plugin not be considered shutdown until all async tasks have terminated, and only then it be reloaded/reinitialized.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 386 Reply Likes

Posted 8 years ago

  • 3

Be the first to post a reply!