Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Offline processing

    I hope someone can help with my problem. It is not anything that I have done before so I don't even know where to start.

    Certain actions on my website require a considerable amount of processing. Rather than make the person wait until the processing is complete, I would like to "fire" off an offline job to do the work. That way, they would get control back immediately and can do other things with their browser.

    The programs have all been written in Perl

    Hoping someone can help.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If this is a "normal" CGI type request and the rest of the processing doesn't send additional data back to the user then there's no reason why you can't send the complete response page back to the user and then perform the rest of the processing in that same script.

    If there is additional information that needs to be relayed to the user then you've got a case for using a popup (a valid use for a popup and the purpose for which popups were made possible) to get the reply leaving the user's main browser free for their use.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To Roy Sinclair

    Thanks for your reply.

    Like I said, I have never done something like this before and I am still trying to get my head around it.

    Firstly, the additional processing does not require anything being sent back to the user so that is not a concern.

    As I understand it, you are saying that I can build an HTML page and send it to the user and then continue processing. I was under the impression that any HTML page built in the script would only be sent when the script finishes regardless of where in the flow it was built. Or am I misunderstanding how CGI works?

    The main point I am not sure of is how I get control back after the page has been sent?

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    In PHP you can use a combination of output buffering (to send data to the client even though the script is still runnning) & ignore_user_abort() to ensure the script completes even after the user has moved on ... now whilst I am sure that this is possible with PERL .. I would not personally know how to tackle that (you should probably be posting this in the PERL forum) , if you have PHP available you can get it to run the PERL scripts using virtual() or similar using the logic above.

    The other option is to get your page to set a flag (in textfile or DB) that script $x needs running for user $y, then have a CRON job running that every 10 minutes or so checks that file/db and runs the scripts for you , it would depend how soon after a request is made that the scripts need to be run to decide whether that was viable or not.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The "how" is partly dependant on what MOD you're using to write your hmtl code to the user. If you're just using the simple "print" verb I think all you need to do will be close the STDOUT file and your content will be sent to the user while the script continues to run and can go ahead and perform the long processing.

    BTW, I'm far from a PERL expert but I do maintain one really huge script and have previously worked on a number of small CGI scripts.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    paris, france
    Posts
    1,216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, i'll tell you about something i did in php, which may or may not be relevant

    i wrote a script to launch a 3D renderer (terragen) but php waits for program return so it took ages. what i did was use this command

    exec("D:\\PROGRA~1\\TERRAGEN\\TERRAGEN.EXE> nul");

    this is the equivelent of command line the >nul means that it sends retun into nowhere, making the php script not wait for it.

    hope that helped (a bit)
    photoshop too expensive? use the GIMP! www.gimp.org


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •