You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Alexey Solofnenko <A....@mdl.com> on 2002/07/02 02:08:31 UTC

RE: What to do if ed program hangs?

Thank you, but replacing existing tasks is dangerous, unless the code will
go into ANT sources. I am already using beta 3. I will try your sources.

Sincerely,
  Alexey Solofnenko.

-----Original Message-----
From: Hal Hildebrand (web) [mailto:Hal.Hildebrand@hellblazer.com]
Sent: Saturday, June 29, 2002 7:39 PM
To: Ant Users List
Subject: Re: What to do if <exec>ed program hangs?
Importance: High


Attached are two patched files to Ant 1.5 beta 2.  With these fixes you
can do:


    <target name="testy" >
        <parallel>
            <sequential>
                ...  Do your testing here ...
                <property name="short_regress_done" value="yes" />
            </sequential>
            <sequential>
                <waitfor maxwait="10}"
                         maxwaitunit="minute"
                         checkevery="1"
                         checkeveryunit="minute">
                    <isset property="test_done" />
                </waitfor>
                <fail unless="test_done" message="Test timed out!" />
            </sequential>
        </parallel>
    </target>

The patched Parallel task's semantics are changed.  If any one of the
parallel threads of the task throws an exception, all the threads are
interrupted.  This means that if you do

<parallel>
    <sequential>
            ... start your server ...
    </sequential>
    <sequential>
            ... wait for server to come up ...
            ... do your tests ...
            ... shutdown the server ...
    </sequential>
</parallel>

and an exception occurs (such as a build exception) in the second
sequential task, the parallel task will exit after interrupting the
first thread.

This is where the second patched file, Execute comes in.  The patch here
is to handle the InterruptedException correctly (or at least handle it)
by always ensuring that the process is destroyed.

Thus if a build exception occurs, the first task (which spawns the
application server process) is interrupted and the process is killed.
Combined with the use of a timeout using the waitfor task, it's a leash
to yank back those pesky processes and make 'em heel.

Combined with the try-finally task from the source forge ant contrib,
you pretty much have all the elements to manage multiple processes in
Ant.

----- Original Message -----
From: "Alexey Solofnenko" <A....@mdl.com>

> Hello,
>
>   we are performing unit testing of our RMI servers during build
process on
> Windows. The tests are started from ANT, but execute in a different
> environment. Unfortunately the servers not always stop correctly and
the
> build hangs. What would be a good way to kill the processes, so ANT
build
> will continue?
>
> - Alexey.
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: What to do if ed program hangs?

Posted by "Hal Hildebrand (web)" <Ha...@hellblazer.com>.
Well, for the parallel, just rename it to Parallel2, and use it as a
foreign task.  As to the patch to execute, the only fix is to the method
waitFor():

    protected void waitFor(Process process) {
        try {
            process.waitFor();
            setExitValue(process.exitValue());
        } catch (InterruptedException e) {
            process.destroy();
        }
    }

Cheers.

BTW, I quit using beta 3 due to OutOfMemory errors after running for
more than 30 minutes of testing.  Just FYI.

----- Original Message -----
From: "Alexey Solofnenko" <A....@mdl.com>

> Thank you, but replacing existing tasks is dangerous, unless the code
will
> go into ANT sources. I am already using beta 3. I will try your
sources.
>
> Sincerely,
>   Alexey Solofnenko.
>
> -----Original Message-----
> From: Hal Hildebrand (web) [mailto:Hal.Hildebrand@hellblazer.com]
> Sent: Saturday, June 29, 2002 7:39 PM
> To: Ant Users List
> Subject: Re: What to do if <exec>ed program hangs?
> Importance: High
>
>
> Attached are two patched files to Ant 1.5 beta 2.  With these fixes
you
> can do:
>
>
>     <target name="testy" >
>         <parallel>
>             <sequential>
>                 ...  Do your testing here ...
>                 <property name="short_regress_done" value="yes" />
>             </sequential>
>             <sequential>
>                 <waitfor maxwait="10}"
>                          maxwaitunit="minute"
>                          checkevery="1"
>                          checkeveryunit="minute">
>                     <isset property="test_done" />
>                 </waitfor>
>                 <fail unless="test_done" message="Test timed out!" />
>             </sequential>
>         </parallel>
>     </target>
>
> The patched Parallel task's semantics are changed.  If any one of the
> parallel threads of the task throws an exception, all the threads are
> interrupted.  This means that if you do
>
> <parallel>
>     <sequential>
>             ... start your server ...
>     </sequential>
>     <sequential>
>             ... wait for server to come up ...
>             ... do your tests ...
>             ... shutdown the server ...
>     </sequential>
> </parallel>
>
> and an exception occurs (such as a build exception) in the second
> sequential task, the parallel task will exit after interrupting the
> first thread.
>
> This is where the second patched file, Execute comes in.  The patch
here
> is to handle the InterruptedException correctly (or at least handle
it)
> by always ensuring that the process is destroyed.
>
> Thus if a build exception occurs, the first task (which spawns the
> application server process) is interrupted and the process is killed.
> Combined with the use of a timeout using the waitfor task, it's a
leash
> to yank back those pesky processes and make 'em heel.
>
> Combined with the try-finally task from the source forge ant contrib,
> you pretty much have all the elements to manage multiple processes in
> Ant.
>
> ----- Original Message -----
> From: "Alexey Solofnenko" <A....@mdl.com>
>
> > Hello,
> >
> >   we are performing unit testing of our RMI servers during build
> process on
> > Windows. The tests are started from ANT, but execute in a different
> > environment. Unfortunately the servers not always stop correctly and
> the
> > build hangs. What would be a good way to kill the processes, so ANT
> build
> > will continue?
> >
> > - Alexey.
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> >
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>