time out if exceeded the time limit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • carobee
    New Member
    • Jun 2007
    • 14

    time out if exceeded the time limit

    Is there any way to monitor the message queue through php script?

    Suppose my php script is receiving message from message queue. i wanted my php scipt to time out if certain sec say 30 sec are exceeded while receiving message from message queue. Is it possible?

    i tried with set_time_limit( ) function but still the script doesnot time out. It waits till it receives the message.

    want urgent help. thanks in advance
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Check the value for max_execution_t ime in php.ini. In what context you are using set_time_limit( )?

    Comment

    • carobee
      New Member
      • Jun 2007
      • 14

      #3
      i checked out , its 30 sec. but i guess when the php script comes to the code of receiving message it goes into wait state. how to take control at that time?

      i used it so that i could set my own time

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        when the php script comes to the code of receiving message
        Please explaing this, from where your script is receiving messages?

        From PHP manual
        When called, set_time_limit( ) restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit( 20) is made, the script will run for a total of 45 seconds before timing out.

        Comment

        • carobee
          New Member
          • Jun 2007
          • 14

          #5
          i m sending message to the php script from a C prog

          Comment

          • mwasif
            Recognized Expert Contributor
            • Jul 2006
            • 802

            #6
            PHP Manual says
            Note: The set_time_limit( ) function and the configuration directive max_execution_t ime only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.
            .

            Did you read the PHP manual?

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Heya, carobee.

              Since PHP doesn't support threading, your script will stop and wait for the system() call to finish before doing anything else.

              If you want to enforce a time limit on your app, it will have to be done in your C program.

              Comment

              • carobee
                New Member
                • Jun 2007
                • 14

                #8
                can i do something like fork a process, let the child process try to receive the process. now since no message is there in the message queue it will go into block state n return control to parent process. As soon as control comes back to the parent process it sends the time out messsage.
                Is somethng like this is feasible?

                Comment

                • carobee
                  New Member
                  • Jun 2007
                  • 14

                  #9
                  i found the solution. Instead of doing in such a complex way i went for a nonblocking message receive call.In this way i could solve the problem easily

                  Comment

                  • pbmods
                    Recognized Expert Expert
                    • Apr 2007
                    • 5821

                    #10
                    Heya, carobee.

                    Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

                    Comment

                    Working...