I'm looking for how to do blocking calls. If I do a blocking call into a dll and don't release the GIL the whole of python is blocked!!!
It says in the C-API whenever you call into a C-DLL with a blocking call you need to release the GIL i.e. the Py_BEGIN_ALLOW_THREADS macro, and when the call returns you need to relock the GIL i.e. Py_END_ALLOW_THREADS. So want to know how to release and acquire the GIL from pure python (i.e. via ctypes or win32). By high performance I mean as high as python can offer - I don't want to poll and select doesn't allow you to check events from the UI - so either WSAAsyncSelect or possibly I/O completion ports. If I need more performance then it'll be a C / C++ extension, but I'd like to get the architecture prototyped in python first. I have a app written in wx that needs to get and send data out of process. All the solutions I've looked at have slow response times (due to polling loops mainly). I have a windows message handler so I should be able to get events from WSAAsyncSelect but I don't know how to release and reacquire the GIL from python if I call a blocking function in a dll. (the select package works fine if the asynchronicity is coming from a socket but not from a UI). Thx David -----Original Message----- From: python-win32-bounces+david.briant=ubs....@python.org [mailto:python-win32-bounces+david.briant=ubs....@python.org] On Behalf Of Tim Roberts Sent: Fri 7-Jan-2011 18:45 To: Python-Win32 List Subject: Re: [python-win32] WSAAsyncSelect david.bri...@ubs.com wrote: > Does anyone know of any links where blocking I/O calls are demonstrated > in pure python? Virtually all I/O calls in pure Python are blocking calls. Did you mean to ask about non-blocking I/O? > I'm currently parsing the c code for _socket.pyd and reading up on > Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. My goal is basically to > produce a high performance socket that I can use with a Windows UI > (wxpython) - so was thinking of calling ws2_32.dll but it looks like I > might need to be a bit more careful. Well, any time I hear "high performance," I start to wonder whether Python is really the right choice. How much performance do you need? WSAAsyncSelect is a pretty snazzy way to deal with a socket server, and I suspect it could be adapted here without much trouble. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32