Bug #2655


win32OLE processes lose their connection?

Added by rogerdpack (Roger Pack) over 12 years ago. Updated over 11 years ago.

Target version:
ruby -v:
ruby 1.9.2dev (2010-01-25 trunk 26409) [i386-mingw32]


The following code works in 1.8.6, not in 1.9.x...

require 'win32ole'
wmi = WIN32OLE.connect("winmgmts://")
processes = wmi.ExecQuery("select * from win32_process")
proc = nil
t = []
processes.each {|process|
t << { sleep 0.1
process.setPriority 32

t.each{|t| t.join}

error is:

E:\dev\ruby\windows_ionice\bin>ruby -v bad.rb
ruby 1.9.2dev (2010-01-25 trunk 26409) [i386-mingw32]
bad.rb:12: warning: shadowing outer local variable - t
bad.rb:8:in method_missing': unknown property or method: setPriority' (WIN32OLERuntimeError)
HRESULT error code:0x80020006
Unknown name.
from bad.rb:8:in block (2 levels) in <main>' from E:/installs/ruby_trunk_installed/lib/ruby/1.9.1/win32ole.rb:13:in call'
from E:/installs/ruby_trunk_installed/lib/ruby/1.9.1/win32ole.rb:13:in `block in initialize'

Actions #1

Updated by mame (Yusuke Endoh) over 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to suke (Masaki Suketa)

Hi, Masaki Suketa

Could you take a look at this ticket?

Yusuke Endoh

Actions #2

Updated by suke (Masaki Suketa) over 12 years ago

To fix this issue, I think Win32OLE should be MTA model instead of STA model.
I had tried MTA instead of STA and fixed this issue, but I have another two
following issues:

(1) WIN32OLE_EVENT does not work very well.
(2) I can't use CoRegisterMessageFilter in MTA model, so I have to fix the
issue in [ruby-dev:35278] without CoRegisterMessageFilter.

And I have not fixed these issues yet.

I'm not sure, but I think I could fix (1) by using critical section
but I don't know how to fix (2).


Actions #3

Updated by mame (Yusuke Endoh) about 12 years ago

  • Status changed from Assigned to Rejected


I think Masaki meant that this bug cannot be fixed.
Do not use win32ole with threads, at least for a while.

If Roger or anyone have an idea to fix this issue, please send us
a patch!

Yusuke Endoh


Also available in: Atom PDF