From: Fyodor Date: 2007-08-07T01:03:05+09:00 Subject: Mac OSX singleton This might be an actual bug in ruby itself. any comments? ---------- Forwarded message ---------- From: Rails Trac Date: Aug 6, 2007 5:40 PM Subject: [Rails Trac] #9202: Mac OSX singleton To: undisclosed-recipients #9202: Mac OSX singleton ----------------------+----------------------------------------------------- Reporter: fygrave | Owner: core Type: defect | Status: new Priority: normal | Milestone: 1.x Component: Railties | Version: edge Severity: normal | Keywords: rails singleton mac osx ----------------------+----------------------------------------------------- There's a problem with Mac OSx singleton class. To make the story short, the singleton doesn't work as singleton on mac osx platform. with every request a new instance of the class is created. mac-2:~/rails/app/models mac$ uname -a Darwin mac-2.local 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386 rails gem version - 1.2.3 to reproduce define a class: foo.rb in models which would look like this: class Foo include Singleton class << self; attr_accessor :Foopipe; end def initialize @cmd = "/bin/sleep 2000" if self.class.Foopipe == nil then self.class.Foopipe = IO.popen(@cmd, "r+") self.class.KMpipe.sync = true self.class.Foopipe.write("something) self.class.KMpipe.flush end end ... the rest of class is not relevant. Foopipe in this example never takes any value, and an instance of the class (and running proccess that could be seen with ps .. ) is created every time when the class is created and accessed... -- Ticket URL: Rails Trac Ruby on Rails -- http://o0o.nu -- http://o0o.nu