Thread, stacktraces, errors and expect. 
Author Message
 Thread, stacktraces, errors and expect.

I'm busy rewriting expect.rb to handle things in bigger chunks. I'm
using it on a slow '486 driving 7 different hardware things lurking at the
end of 7 serial ports. I'm rewriting expect to use one Thread, and a
single select for all ports and sysread instead of getch.

Things are progressing quite well except when things go wrong in a Thread,
then all I know about it is something doesn't work. No error message,
stack trace nothing.

Is there a way of convincing ruby to do like Java...
 try {
   // something that may die messily
   .
   .
 } catch (Exeception e) {
   e.printStackTrace();
 }

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632

New Zealand

May contain traces of nuts. This email was packed by mass, not
volume. Contents may have settled during distribution.
This email is not designed or intended for use in on-line control of
aircraft, air traffic, aircraft navigation or aircraft communications; or in
the design, construction, operation or maintenance of any nuclear
facility. Reader represents and warrants that it will not use or
redistribute the email for such purposes.



Mon, 01 Nov 2004 06:09:52 GMT  
 Thread, stacktraces, errors and expect.

Quote:

> I'm busy rewriting expect.rb to handle things in bigger chunks. I'm

Which expect.rb is it that you are rewriting?

Quote:
> using it on a slow '486 driving 7 different hardware things lurking at the
> end of 7 serial ports. I'm rewriting expect to use one Thread, and a
> single select for all ports and sysread instead of getch.

In Ruby, when multiple threads are waiting on IO, the interpreter makes
a single call to select() internally.  I'm not sure if there will be
much of a performance benefit in single thread/one select over multiple
threads.

Quote:
> Things are progressing quite well except when things go wrong in a Thread,
> then all I know about it is something doesn't work. No error message,
> stack trace nothing.

> Is there a way of convincing ruby to do like Java...
>  try {
>    // something that may die messily
>    .
>    .
>  } catch (Exeception e) {
>    e.printStackTrace();
>  }

I don't know of a good way to print a stack trace in Ruby, though a nice
interface to eval.c's error_print would certainly be nice.  As an
alternative, you can do this:

  def exception_str(exc=$!)
    str = ''
    first = true
    exc.backtrace.each do |bt|
      str << (first \
        ? "#{bt}: #{exc.message} (#{exc.type})\n" \
        : "\tfrom #{bt}\n")
      first = false
    end
    str
  end

  def print_exception(exc=$!, out=$stdout)
    out.puts exception_str(exc)
  end

  begin
    # ...
  rescue Exception
    print_exception()
  end

Paul



Mon, 01 Nov 2004 06:25:36 GMT  
 Thread, stacktraces, errors and expect.

Quote:

> Things are progressing quite well except when things go wrong in a Thread,
> then all I know about it is something doesn't work. No error message,
> stack trace nothing.

Does setting
  Thread.abort_on_exception = true
help?


Mon, 01 Nov 2004 06:30:48 GMT  
 Thread, stacktraces, errors and expect.

Quote:


> > Things are progressing quite well except when things go wrong in a Thread,
> > then all I know about it is something doesn't work. No error message,
> > stack trace nothing.

> Does setting
>   Thread.abort_on_exception = true
> help?

By gorrah! How did I miss that! Thank 'ee kindly Sir, you have saved my
day.

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632

New Zealand

May contain traces of nuts. This email was packed by mass, not
volume. Contents may have settled during distribution.
This email is not designed or intended for use in on-line control of
aircraft, air traffic, aircraft navigation or aircraft communications; or in
the design, construction, operation or maintenance of any nuclear
facility. Reader represents and warrants that it will not use or
redistribute the email for such purposes.



Mon, 01 Nov 2004 07:02:06 GMT  
 Thread, stacktraces, errors and expect.

Quote:


> > I'm busy rewriting expect.rb to handle things in bigger chunks. I'm

> Which expect.rb is it that you are rewriting?

The one in /usr/local/lib/ruby/1.6/expect.rb (If you speak unix...)

Is there another?

Quote:
> > using it on a slow '486 driving 7 different hardware things lurking at the
> > end of 7 serial ports. I'm rewriting expect to use one Thread, and a
> > single select for all ports and sysread instead of getch.

> In Ruby, when multiple threads are waiting on IO, the interpreter makes
> a single call to select() internally.  I'm not sure if there will be
> much of a performance benefit in single thread/one select over multiple
> threads.

I'm not sure either. I noticed that when I was debugging something, but
was fairly far along this path. I'll probably try both and benchmark.

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632

New Zealand

May contain traces of nuts. This email was packed by mass, not
volume. Contents may have settled during distribution.
This email is not designed or intended for use in on-line control of
aircraft, air traffic, aircraft navigation or aircraft communications; or in
the design, construction, operation or maintenance of any nuclear
facility. Reader represents and warrants that it will not use or
redistribute the email for such purposes.



Mon, 01 Nov 2004 07:17:43 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Expect: error with puts after expect

2. GNAT Need StackTrace on unhandled exception

3. getting java stacktrace info in jython

4. get stacktrace as string

5. How do i produce a stacktrace by hand ?

6. EXPECT EXCEPTION ERROR - slavedrv.exe Application error

7. Threads creating threads creating threads...

8. thread, threading, mutex modules and non-threading interpreters

9. Thread & Expect

10. Threads with Expect/Tcl

11. expect - thread safe?

12. Threaded expect

 

 
Powered by phpBB® Forum Software