Project

General

Profile

Actions

Bug #4405

closed

WIN32OLE & Threads incompatible

Added by larsch (Lars Christensen) about 13 years ago. Updated about 3 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2p136 (2010-12-25) [i386-mingw32]
Backport:
[ruby-core:35280]
Tags:

Description

=begin
The WIN32OLE library does not work when using Ruby threads. It may raise exceptions such as this:

(druby://localhost:2002) threadsys.rb:7:in connect': failed to parse display name of moniker winmgmts://localhost/root/cimv2' (WIN32OLERuntimeError)

WIN32 OLE api's are not generally Thread safe, and it can be argued that it is the user's task to ensure that it is accessed only from one thread, or the main thread. However, there are some complications;

  • Using WIN32OLE from DRb (DRb can not be used without Threads).
  • Using WIN32OLE indirectly (e.g. through Sys::ProcTable).

My specific case was a DRb server that examined processes using Sys::ProcTable, which happen to use WIN32OLE. This causes an exception. Attached is a simple script that recreates the problem. Note that in this simple case, WIN32OLE is only invokes once, and only from one single thread (and it still throws the exception).
=end


Files

threadsys.rb (257 Bytes) threadsys.rb Recreates the exception from WIN32OLE larsch (Lars Christensen), 02/17/2011 05:45 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0