[MacRuby-devel] UTF8 Strings

s.ross cwdinfo at gmail.com
Sun Dec 6 19:26:01 PST 2009


On Dec 6, 2009, at 6:41 PM, Laurent Sansonetti wrote:

> Hi Steve,
> 
> On Dec 5, 2009, at 5:10 PM, s.ross wrote:
>> What I really want to use is Nokogiri. My main issue is that I'm having to reimplement XML-RPC because the Ruby Std. Lib version is broken over SSL. Even if it weren't it's never been thread safe and thus can't operate asynchronously. As a result, what I have is an XML document inside an XML-RPC response envelope. That means I have to parse the document once to get the contents of the envelope (which is HTML-escaped), then parse those contents to get an XML document I can work with. I've been using XPath for that, and that's why I haven't moved over the NSXMLDocument.
>> 
>> Maybe I'm missing a bet here and should shift my strategy. I'll do some more reading...
> 
> Did you file a bug on our tracker regarding the stdlib breakage? Is it related to timeout.rb? It looks like there is a MacRuby problem that should be fixed :)

I didn't file a bug because the problem I am working on requires Net::HTTP over SSL to retrieve the XML. That was simply not working, so I just went ahead and used NSURL. As I understand the issue, Net::HTTP does not protect the buffer in a multithreaded environment. Here's where I ran up against the problem (pseudo code)

- HTTPS Get photo_id for nth 20 pictures
- In groups of 5 spin off a thread to HTTPS Get details for the pictures

The numbers 20 and 5 simply correspond to what the Web Service gives me. The idea is that because of network latency and the blocking nature of the HTTP traffic, there would likely be some parallelism achieved. It turns out this strategy is a huge win ... except that there is no concept of thread-local scope (some might contend that is an evil concept :), and thus the buffers used by Net::HTTP are at risk of corruption when used this way in a multithreaded environment. Long way of saying, if there's a bug, I am sure it's in MRI as well.

> Laurent
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list