Blocking Calls on Win32 Ruby


(Bret Pettichord) #1

I am running into several problems with some Ruby code. It was written on a
Mac and i am trying to get it to run on my Windows box. I am using the
Win32 Ruby 1.6.8. I’ve done some reading around and it seems that the
problems i am seeing are caused by something i read about.

Apparently, certain blocking calls block all threads rather than just their
own thread. This is apparently the consequent of the use of pthreads.

My next step is to try the same code with cygwin ruby or linux ruby. (I
don’t have a mac). I understand that both of these use better-behaved threads.

Am i on track here? Have i misunderstood something terribly? Are there
plans to change this with 1.8 or later?

Bret

···

Bret Pettichord, Software Tester
Book - www.testinglessons.com
Consulting - www.pettichord.com
Blog - www.io.com/~wazmo/blog
Hotlist - www.testinghotlist.com


#2

Bret - I had the same issues on Windows. I was trying to use the
serial port with an FXRuby gui. I ended up having the serial driver in
a seperate ruby script, talking to the main app with drb

Bret Pettichord bret@pettichord.com wrote in message news:5.1.0.14.2.20040216235853.038bacd0@127.0.0.1

···

I am running into several problems with some Ruby code. It was written on a
Mac and i am trying to get it to run on my Windows box. I am using the
Win32 Ruby 1.6.8. I’ve done some reading around and it seems that the
problems i am seeing are caused by something i read about.

Apparently, certain blocking calls block all threads rather than just their
own thread. This is apparently the consequent of the use of pthreads.

My next step is to try the same code with cygwin ruby or linux ruby. (I
don’t have a mac). I understand that both of these use better-behaved threads.

Am i on track here? Have i misunderstood something terribly? Are there
plans to change this with 1.8 or later?

Bret


Bret Pettichord, Software Tester
Book - www.testinglessons.com
Consulting - www.pettichord.com
Blog - www.io.com/~wazmo/blog
Hotlist - www.testinghotlist.com


(Shashank Date) #3

“Bret Pettichord” bret@pettichord.com wrote in message

Apparently, certain blocking calls block all threads rather than just
their
own thread. This is apparently the consequent of the use of pthreads.

Yes, for example calls to gets in a thread will block all other threads.
But I don’t think this has anything to do with pthreads. (See lines 8006
onwards of eval.c)

My next step is to try the same code with cygwin ruby or linux ruby. (I
don’t have a mac). I understand that both of these use better-behaved
threads.

At least the gets problem goes away on Cygwin.

Have i misunderstood something terribly?

Not really … if you could show the code we can talk about the specifics.
HTH,
– shanko


(Bret Pettichord) #4

Well, i am porting 18,000 lines of ruby originally written on the Mac so
that they will run on Windows. Do you want me to send all of it to you?

OK. Here’s an update. I’ve got all that code working (except for a few
minor problems) using the cygwin ruby. That’s cool.

The problem is that i need to hook up that code, which is a web
application, to some ruby scripts that drive Internet Explorer’s COM
interface. Guess what? That code will only work on mswin32 ruby because
cygwin doesn’t support OLE/COM.

This was what i want to do:

  • start the web application in a separate thread/process
  • run the tests using IEC
  • stop the web application.

My head has been hurting all day as i try to go back and forth from
thinking in cygwin ruby vs mswin32 ruby. I think i can do this if i put the
main thread in cygwin ruby and then have it spawn one thread/process to run
the server in cygwin ruby and other thread/process to run the iec tests in
mswin32 ruby.

Honestly, it is making me think that Python looks pretty good in comparison.

Bret

···

At 07:34 PM 2/17/2004, Shashank Date wrote:

Not really … if you could show the code we can talk about the specifics.
HTH,


Bret Pettichord, Software Tester
Book - www.testinglessons.com
Consulting - www.pettichord.com
Blog - www.io.com/~wazmo/blog

Homebrew Automation Seminar
March 19, Redmond, Washington
www.sasqag.org/99days/#automation

(Shashank Date) #5

Well, i am porting 18,000 lines of ruby originally written on the Mac so
that they will run on Windows. Do you want me to send all of it to you?

Whoa ! That is a lot of code …not sure if I can handle it :wink:

OK. Here’s an update. I’ve got all that code working (except for a few
minor problems) using the cygwin ruby. That’s cool.

Yes, cool !

The problem is that i need to hook up that code, which is a web
application, to some ruby scripts that drive Internet Explorer’s COM
interface. Guess what? That code will only work on mswin32 ruby because
cygwin doesn’t support OLE/COM.

Unfortunately, yes.

This was what i want to do:

  • start the web application in a separate thread/process
  • run the tests using IEC
  • stop the web application.

Take a look at win32-process 0.1.0 It provides fork() functionality, albeit
with some limitations.

My head has been hurting all day as i try to go back and forth from
thinking in cygwin ruby vs mswin32 ruby. I think i can do this if i put
the
main thread in cygwin ruby and then have it spawn one thread/process to
run
the server in cygwin ruby and other thread/process to run the iec tests in
mswin32 ruby.

My head hurts just by reading it !

Honestly, it is making me think that Python looks pretty good in
comparison.

PyWin32 is very feature rich.

– shanko


(Bret Pettichord) #6

I got the two kinds of ruby to run in parallel using drb to allow one to
make calls in the other. Works slick!

···

At 11:24 AM 2/22/2004, Shashank Date wrote:

My head has been hurting all day as i try to go back and forth from
thinking in cygwin ruby vs mswin32 ruby. I think i can do this if i put
the
main thread in cygwin ruby and then have it spawn one thread/process to
run
the server in cygwin ruby and other thread/process to run the iec tests in
mswin32 ruby.

My head hurts just by reading it !


Bret Pettichord, Software Tester
Book - www.testinglessons.com
Consulting - www.pettichord.com
Blog - www.io.com/~wazmo/blog

Homebrew Automation Seminar
March 19, Redmond, Washington
www.sasqag.org/99days/#automation

(Shashank Date) #7

“Bret Pettichord” bret@pettichord.com wrote in message

I got the two kinds of ruby to run in parallel using drb to allow one to
make calls in the other. Works slick!

I bet it does ! And now it is instantly distributed too !
You have the possibility of running the iec tests on multiple machines
simultaneously … without knowing the exact nature of these tests, I don’t
know if this even makes sense.

Any chance of the software being open-source ? Just being greedy :wink:

– shanko

···

Did you pursue the PyWin32 approach any further?