From: Lars Christensen Date: 2011-02-17T17:45:15+09:00 Subject: [ruby-core:35280] [Ruby 1.9-Bug#4405][Open] WIN32OLE & Threads incompatible --mimepart_4d5ce01637fc8_5986916e136110f8 Content-Type: text/plain Content-Transfer-Encoding: Quoted-printable Content-Disposition: inline Bug #4405: WIN32OLE & Threads incompatible http://redmine.ruby-lang.org/issues/show/4405 Author: Lars Christensen Status: Open, Priority: Normal Category: ext ruby -v: ruby 1.9.2p136 (2010-12-25) [i386-mingw32] 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 dis= play name of moniker `winmgmts://localhost/root/cimv2' (WIN32OLERuntimeEr= ror) 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::Proc= Table, which happen to use WIN32OLE. This causes an exception. Attached = is a simple script that recreates the problem. Note that in this simple c= ase, WIN32OLE is only invokes once, and only from one single thread (and = it still throws the exception). ---------------------------------------- http://redmine.ruby-lang.org --mimepart_4d5ce01637fc8_5986916e136110f8 Content-Type: text/plain; name=threadsys.rb Content-Transfer-Encoding: Base64 Content-Disposition: attachment; filename=threadsys.rb cmVxdWlyZSAnZHJiJw0KcmVxdWlyZSAnd2luMzJvbGUnDQpjbGFzcyBTZXJ2 ZXINCiAgZGVmIHNlcnZlDQogICAgV0lOMzJPTEUuY29ubmVjdCgid2lubWdt dHM6Ly9sb2NhbGhvc3Qvcm9vdC9jaW12MiIpDQogIGVuZA0KZW5kDQpzZXJ2 ZXIgPSBTZXJ2ZXIubmV3DQpEUmIuc3RhcnRfc2VydmljZSgiZHJ1Ynk6Ly86 MjAwMiIsIHNlcnZlcikNCnMgPSBEUmJPYmplY3QubmV3KG5pbCwgImRydWJ5 Oi8vbG9jYWxob3N0OjIwMDIiKQ0KcCBzLnNlcnZlDQo= --mimepart_4d5ce01637fc8_5986916e136110f8--