in reply to Re: Using parent and child processes in perl
in thread Using parent and child processes in perl

My service call is not slow, the time it takes to return the data is long! How do I output lines while processing? Could you elaborate on that please?
  • Comment on Re^2: Using parent and child processes in perl

Replies are listed 'Best First'.
Re^3: Using parent and child processes in perl
by Anonymous Monk on Jul 15, 2013 at 09:39 UTC
    My service call is not slow, the time it takes to return the data is long!

    Aren't those the same thing? Or does "it" refer to the processing of your CGI script?

    How do I output lines while processing? Could you elaborate on that please?

    It really depends on what this "processing" of yours means. Where does it take time? What sort of structure does it have? Do post code if possible.

    Anyway, you should be looking into chopping the processing into smaller pieces by e.g. converting it to an iterator, and doing the intermediate output between those stages.

    If all your processing time is taken inside a single subroutine call you can't modify, there isn't much you can do; some things may be possible to solve with alarm(), but it's usually not a good fit for this.

    However, since you mentioned that the request takes four or five minutes, it is a good idea to not do the processing on the web server at all, but do it in the background with a separate process: you'll just need to communicate with it (e.g. through a file or database) to queue a job with it. Needs a bit more infrastructure but is probably the easiest approach!