Again threading problems.

H

Hello There

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
 
R

Roger Pack

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
 
I

Ian Hobson

Roger said:
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
 
R

Robert Klemme

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
 
C

Charles Oliver Nutter

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

Brian Candler

Hello said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top