Re: Cocoa, httplib and threads?

Ronald Oussoren <[email protected]>
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
On 15 Jul, 2011, at 3:43, Greg Ewing wrote:

> I'm trying to use httplib to send an http request in
> a background thread. It works fine on its own, but when
> I do it inside a Cocoa application, the thread hangs
> as soon as it tries to send the request.
> 
> It doesn't seem to be a GIL problem, because I can do
> other things in the thread leading up to that point.
> It's just sending the request that seems to block.
> 
> Is there anything I should be aware of when using
> the threading module in conjunction with pyobjc?

This should work.  One thing you could try is redefining urllib. proxy_bypass_macosx_sysconf and urllib.getproxies_macosx_sysconf

def getproxies_macosx_sysconf():
   return {}

def proxy_bypass_macosx_sysconf(host):
   return True

urllib. getproxies_macosx_sysconf = getproxies_macosx_sysconf
urllib.proxy_bypass_macosx_sysconf = proxy_bypass_macosx_sysconf

This ensures that urllib doesn't use the OSX specific code for getting the HTTP proxy configuration.   That code should work just fine in a Cocoa program, but it does call into Apple's frameworks and hence might cause problems in some way.

Ronald
> -- 
> Greg
> 
> ------------------------------------------------------------------------------
> AppSumo Presents a FREE Video for the SourceForge Community by Eric 
> Ries, the creator of the Lean Startup Methodology on "Lean Startup 
> Secrets Revealed." This video shows you how to validate your ideas, 
> optimize your ideas and identify your business strategy.
> http://p.sf.net/sfu/appsumosfdev2dev
> _______________________________________________
> Pyobjc-dev mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev

_______________________________________________
Pyobjc-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
smime.p7s (application/pkcs7-signature, 2.2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.