curl-and-python

Help with curl_multi_socket interface

From: Yuhui H <eyecat_at_gmail.com>
Date: Mon, 9 Jun 2008 14:31:19 -0700

Hi,

(Not sure if this should go to the main libcurl list).

I'm trying to add curl_multi_socket to PycURL but it didn't work out
as expected. I've attached a patch (against current pycurl HEAD).

It should be pretty straightforward. I wrapped
curl_multi_socket_action and curl_multi_socket_all, plus some
constants. Then I modified tests\test_multi_socket.py to use a
select() call to dispatch the sockets. Relavent code snippet below:

while True:
    (rr, wr, er) = select.select(sockets,sockets,sockets,timeout/1000.0)
    socketSet = set(rr+wr+er)
    if socketSet:
        for s in socketSet:
            while True:
                (ret,running) = m.socket_action(s,0)
                if ret!=pycurl.E_CALL_MULTI_PERFORM:
                    break
    else:
        (ret,running) = m.socket_action(pycurl.SOCKET_TIMEOUT,0)
    if running==0:
        break

I'm running Win32, Visual C++ 2003, LibCurl CVS HEAD. It doesn't work
as expected.

First iteration of select() goes through. On second iteration select()
generates this error: "An operation was attempted on something that is
not a socket".

If I replace the entire "select() call mechanism" with a repeated call
to m.socket_all(), the script seems to work fine. Of course that would
be missing the point of curl_multi_socket interface.

Now my question is, have there been any confirmed success of using
curl_multi_socket interface on Win32? I know I should try any of
these:

  - Programming curl_multi_socket in C/on Win32 (thus isolate
potential python select issue)
  - Try the modification on Linux

But neither of those options is convinient for me at the moment. Any
suggestion in how I should investigate next would be greatly
appreciated.

Yuhui

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python

Received on 2008-06-09