From: Allison N. <dem...@ma...> - 2009-02-15 07:21:30
|
Oh, yeah, I should have seen that. You walked straight into GIL deadlock hell. It's a good lesson to learn though - if you're going to call a blocking Cocoa function, make sure that there is never a call back into Ruby during the treatment of the function. I normally work around this by writing an obj-c wrapper for the function that doesn't block (the equivalent of choosing a non-blocking version of the API if it exists). Does anyone know of a more elegant solution to this? Envoyé de mon iPhone Le 15 févr. 09 à 05:09, Steve Conover <sco...@gm...> a écrit : > For the record... > > I had an rtfm problem, I was using > NSURLConnection.sendSynchronousRequest_returningResponse_error, which, > according to the docs: > > "A synchronous load is built on top of the asynchronous loading code > made available by the class. The calling thread is blocked while the > asynchronous loading system performs the URL load on a thread spawned > specifically for this load request. No special threading or run loop > configuration is necessary in the calling thread in order to perform a > synchronous load." > > I'm still fuzzy on the details here but the key seems to be the > blocking part. So I switched to an asynchronous and got it to work. > > Thanks for your suggestions Allison. > > -Steve > > On Sat, Feb 14, 2009 at 4:48 PM, Steve Conover <sco...@gm...> > wrote: >> I agree that the class methods aren't the problem - it appears to me >> like the initialization may have completed, and somewhere on the way >> to calling startLoading there's either a blocking call that I'm not >> aware of, or something else. >> >> What are the tools the Rubycocoa people bring to bear when there's a >> mystery like this? Is there a debugger one can easily fire up to see >> what's going on? Ruby-debug isn't much help - the hang is apparently >> just after the return from canonicalRequestForRequest... >> >> -Steve >> >> On Sat, Feb 14, 2009 at 12:55 PM, Allison Newman >> <dem...@ma...> wrote: >>> I don't have any good ideas as to what is going wrong, except to say >>> that it would appear to me that the injection of class methods is >>> not >>> the real problem, it's a red-herring. you can see in the trace that >>> they are correctly called, and they return without any obvious >>> problems, so I'm guessing the real problem is elsewhere. >>> >>> What happens if you remove either the definition of the function, >>> the >>> call to objc_class_method, or both? Does it still work, or does it >>> hang? Have you tried implementing the class in Objective-C to see >>> what happens (this would at least make sure that you are returning >>> reasonable values from your functions, if it works in obj-c). I'm >>> wondering about that 0 that you return for canInitWithRequest: >>> isn't >>> that function supposed to return a boolean, hence false, rather >>> than 0? >>> >>> Ummm, apart from that, I'm not too familiar with NSURLProtocol, so I >>> can't offer up any special insight to the actual implementation :-) >>> >>> >>> Le 14 févr. 09 à 20:35, Steve Conover a écrit : >>> >>>>>> objc_class_method(:canInitWithRequest_, '@:@@') >>>>>> def self.canInitWithRequest(ns_url_request) >>>>>> p" canInitWithRequest" >>>>>> 0 >>>>>> end >>> >>> >>> --- >>> --- >>> --- >>> --- >>> ------------------------------------------------------------------ >>> Open Source Business Conference (OSBC), March 24-25, 2009, San >>> Francisco, CA >>> -OSBC tackles the biggest issue in open source: Open Sourcing the >>> Enterprise >>> -Strategies to boost innovation and cut costs with open source >>> participation >>> -Receive a $600 discount off the registration fee with the source >>> code: SFAD >>> http://p.sf.net/sfu/XcvMzF8H >>> _______________________________________________ >>> Rubycocoa-talk mailing list >>> Rub...@li... >>> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk >>> >> > > --- > --- > --- > --------------------------------------------------------------------- > Open Source Business Conference (OSBC), March 24-25, 2009, San > Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the > Enterprise > -Strategies to boost innovation and cut costs with open source > participation > -Receive a $600 discount off the registration fee with the source > code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |