Again threading problems

Hello.

I am now coding a small application that should do the following:

  1. User inputs timestamps in a file.
  2. Application starts a thread and check every second if the current
    time is equal to any timestamp in the file (stored in a struct however).
  3. If its time, the thread call a function, a http post using mechanize.
  4. Application should be runable both on linux and windows.

However, i have gotten some big problems, first, there were a bug with
threads in ruby 1.8.6 and standard I/O (gets) + windows, however I got
help here on the ruby forum to fix that with an alternative input
method.

What the problem is now that the function i am calling in the thread
doesn’t run anyway(some problem with mechanize and threads aswell?)
since the function runs fine when i for example place it in initialize
for the class. And I can comment out the function and for example just
change a variable in it and it works fine aswell.

So I heard that in 1.9.1 there should be no bugs like this, however I
haven’t yet found a way to fully install ruby 1.9.1(on windows) with
mechanize (+ needs nokogiri), when trying to install them I always gets
some kind of errors for missing .so files etc.

Anyone managed to install 1.9.1 + mechanize(+nokogiri)?
Anyone had the same problem as me?
What do people normally do when coding things like this?, I mean, the
things that the application do shouldn’t be that unusual.

Best regards

What the problem is now that the function i am calling in the thread
doesn’t run anyway(some problem with mechanize and threads aswell?)
since the function runs fine when i for example place it in initialize
for the class. And I can comment out the function and for example just
change a variable in it and it works fine aswell.

Setting Thread.abort_on_exception=true might help you

Anyone managed to install 1.9.1 + mechanize(+nokogiri)?
Tried it once and [very quickly] gave up once I realized it had lots of
dependencies. I suppose you could install them using mingw…might be
hard, though. Cygwin might have a working shot at it. Another idea
might be virtualbox+linux or andlinux.
Cheers!
-=r

Thank you for answer.
Yeah well, switching to linux would be the only option?
Since according to this article(watch strike 3):
http://cbcg.net/2007/04/22/python-up-ruby-down-if-that-runtime-dont-work-then-its-bound-to-drizzown.html

MingW doesn’t work either according to this, this person seems to have
kinda the same problem with ruby as I.

Only other option is to switch to linux?

So with other words, using linux in some way is the best alternative?

Hello There wrote:

So with other words, using linux in some way is the best alternative?

If you get desperate enough :slight_smile:
-=r

Roger P. wrote:

Another idea
might be virtualbox+linux or andlinux.

On the Windows platform, VMWare Server works well, and is free of
charge.

The management interface will complain that it needs a server version,
and on Win2K, you do have to start
it manually. It also needs lots of RAM and CPU oomph.

I have run a Ubuntu desktop on an AMD 3500+ with 2GB, and it was nice
to use. (Naturally you can’t play games or watch video on a guest).

Compared to my attempts at loading Linux, adding KVM and getting windows
to run as a guest it was a dream!

Regards

Ian

Just run JRuby. Install Java, unpack JRuby, done. Fast, real parallel
threads.

On 30.05.2009 18:39, Hello There wrote:

So with other words, using linux in some way is the best alternative?

cygwin genereally works well and provides an environment which is pretty
close to linux with the added benefit that you do not have to go through
some form of Samba or VMWare configuration to make Windows folders
accessible from a VM. My 0.02EUR…

Cheers

robert

Hello There wrote:

What the problem is now that the function i am calling in the thread
doesn’t run anyway(some problem with mechanize and threads aswell?)
since the function runs fine when i for example place it in initialize
for the class. And I can comment out the function and for example just
change a variable in it and it works fine aswell.

My advice is just to fix your program in 1.8.6 or 1.8.7. Threads work
absolutely fine in 1.8, and as has been pointed out, you’re on your own
if you have complex library dependencies with 1.9, as lots of 3rd-party
libraries don’t work with 1.9.

As already advised, Thread.abort_on_exception = true should help you
find out what’s going wrong in your thread. Or else you can add a bit of
debugging yourself:

Thread.new do
begin
… normal stuff
rescue Exception => e
$stderr.puts “#{e}\n\t#{e.backtrace.join(”\n\t")}"
end
end