multithreading sysread error

V

Venkat Bagam

Hi All,

I am a newbie at scraping and multi-threading too. Recently, I
have to implement these two in one of my application. Please find my
code in the attachment. I was facing some peculiar issues and the reason
I don't know!!! The code works pretty well on my ubuntu7.04 but throws
some "sysread", "read_status_line" errors when run on Windows. What
could be the obvious problem? Any help greatly appreciated.

regards,
Venkat Bagam

Attachments:
http://www.ruby-forum.com/attachment/1517/scrape.rb
 
M

MenTaLguY

There are a number of problems, among them:

1. deriving from Monitor does not do anything for you in
this case, since you don't use any of its locking
facilities (deriving from Monitor like this probably
isn't a good approach anyway)

2. WWW::Mechanize instances are not safe to share
between threads; it's best to create a separate agent
per thread.

3. Using the Timeout class on complicated libraries
can often break them. If you really need operations
to time out, it is best to see if the library provides
direct support for timeouts on its operations.

-mental
 
D

Daniel Brumbaugh Keeney

Hi All,

I am a newbie at scraping and multi-threading too. Recently, I
have to implement these two in one of my application. Please find my
code in the attachment. I was facing some peculiar issues and the reason
I don't know!!! The code works pretty well on my ubuntu7.04 but throws
some "sysread", "read_status_line" errors when run on Windows. What
could be the obvious problem? Any help greatly appreciated.

regards,
Venkat Bagam

sysread uses a "low-level" read. In general, I wouldn't be confident
that anything marked as "low-level" can be mixed well with
multi-threading. On my system, sysread is slower than ordinary read,
so I fail to see the advantage versus the standard IO#read.

Daniel Brumbaugh Keeney
 
V

Venkat Bagam

Mental said:
There are a number of problems, among them:

1. deriving from Monitor does not do anything for you in
this case, since you don't use any of its locking
facilities (deriving from Monitor like this probably
isn't a good approach anyway)

I used a synchronized block in "download_file(html_link)"
method...Doesn't that make any sense of locking ??? Am I wrong again !!!
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top