RSS/Atom feed Twitter
Site is read-only, email is disabled

Script-fu-server and queuing

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 5 messages available
Toggle history

Please log in to manage your subscriptions.

Script-fu-server and queuing Oscar Picasso 05 Jul 16:22
  Script-fu-server and queuing Sven Neumann 05 Jul 17:00
   Script-fu-server and queuing Marc) (A.) (Lehmann 07 Jul 16:56
87d638c15g.fsf@gimp.org 07 Oct 20:23
  Script-fu-server and queuing Oscar Picasso 07 Jul 02:42
Oscar Picasso
2004-07-05 16:22:57 UTC (almost 20 years ago)

Script-fu-server and queuing

Hi,

I use the script-fu-server and came across this remark at http://people.westminstercollege.edu/students/d-b1649/linux/gimp_server.html

Adding a Queue

Because the Gimp was not originally designed as a server, it does not follow some conventions that are necessary for such a mode. This includes the issue of managing shared resources among different threads of execution. A few of the resources that are not 'thread-safe' include the current foreground/background color and brush shape.

An example of the severity of this problem is if you are running two Perl scripts at once on the same Gimp server. Let's say that the first script needs to write some white text on a black background, and the second one needs to write black text on a white background. Because the two are running at the same time, the following sequence of events may occur:

1. #1 sets the foreground color to white. 2. #2 sets the foreground color to black. 3. #1 writes some text to its black image, using the current foreground color (which is now black.)
4. #2 writes some text to its white image, using the current foreground color (still black.)

Obviously, script #1 ends up with an image that has the incorrect color of text. The solution to this problem is to only allow the Gimp server to run one script at a time. This is easier said than done, especially if you have multiple scripts that run every few minutes. What you need to do is create a queue system that maintains a list of scripts that need to be run and have a separate program feed them into the Gimp, one by one. When a script wants to run, it is submitted to the queue and waits for its turn. This kind of system is almost identical to print queues, where multiple computers share one printer.

On the other hand I took a look at the gimp sources and it seems there is some kind of queuing mechanism build inside gimp.

I have also read the post "http://marc.theaimsgroup.com/?l=gimp-developer&m=103142913407902&w=2" about queuing (for perl-fu, but I guess it's the same for script-fu)

From this post it seems that I can safely sent multiple concurrent requests to

the script-fu-server (apart the problem of memory consumption raised by the initial poster of that thread).

What is the reality in this regard? Do I have to build my own queue or is it handled by gimp.

I use v 1.2.3 but plan to upgrade to gimp 2.0. Is there a difference in that respect between the two versions?

Thanks.

Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
Sven Neumann
2004-07-05 17:00:36 UTC (almost 20 years ago)

Script-fu-server and queuing

Hi,

Oscar Picasso writes:

I use the script-fu-server and came across this remark at http://people.westminstercollege.edu/students/d-b1649/linux/gimp_server.html

Adding a Queue

Because the Gimp was not originally designed as a server, it does not follow some conventions that are necessary for such a mode. This includes the issue of managing shared resources among different threads of execution. A few of the resources that are not 'thread-safe' include the current foreground/background color and brush shape.

An example of the severity of this problem is if you are running two Perl scripts at once on the same Gimp server. Let's say that the first script needs to write some white text on a black background, and the second one needs to write black text on a white background. Because the two are running at the same time, the following sequence of events may occur:

1. #1 sets the foreground color to white. 2. #2 sets the foreground color to black. 3. #1 writes some text to its black image, using the current foreground color (which is now black.)
4. #2 writes some text to its white image, using the current foreground color (still black.)

Obviously, script #1 ends up with an image that has the incorrect color of text. The solution to this problem is to only allow the Gimp server to run one script at a time. This is easier said than done, especially if you have multiple scripts that run every few minutes. What you need to do is create a queue system that maintains a list of scripts that need to be run and have a separate program feed them into the Gimp, one by one. When a script wants to run, it is submitted to the queue and waits for its turn. This kind of system is almost identical to print queues, where multiple computers share one printer.

I don't think a queue is the way to go here. In gimp-2.0 we have introduced the concept of a GimpContext that holds the foreground and background colors, current brush, pattern, gradient and all that. The solution is though to let each script/plug-in run in it's own context. We didn't do that yet because some scripts rely on the possibility to manipulate the user context. The best thing to solve this is probably to let scripts work in their own context by default and add an API to manipulate the user context.

Sven

Oscar Picasso
2004-07-07 02:42:02 UTC (almost 20 years ago)

Script-fu-server and queuing

My solution is not yet implemented. But a lot of what needs to be done is in GIMP 2.0 already. There's really no good reason not to use GIMP 2.0.

I would love to. I tried to install the rpm for fedora core 1 but it didn't work. I also tried to compile it but I've very busy now. I will try again as soon as I have some time.

Did you mean to send this mail to the mailing-list? I'd prefer to have such discussions on the list so please respect that and move the discussion back to the list.

It was intended for the list. I'm just realizing that the list address doesn't appear on the "To" field, unlike other lists I use, so the "reply" instinct doesn't work here.

Oscar

___

Marc) (A.) (Lehmann
2004-07-07 16:56:44 UTC (almost 20 years ago)

Script-fu-server and queuing

Because the Gimp was not originally designed as a server, it does not follow some conventions that are necessary for such a mode. This includes the issue of managing shared resources among different threads of execution. A few of the resources that are not 'thread-safe' include the current foreground/background color and brush shape.

Your can work around this problem by using Gimp::lock until it is solved.