curl-and-python

Re: Help with curl_multi_socket interface

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 10 Jun 2008 00:02:49 +0200 (CEST)

On Mon, 9 Jun 2008, Yuhui H wrote:

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

You'll most certainly reach more people with multi API experience on that
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).

I would suggest you first write a stand-alone application in C to get a grip
of the concepts and see that it works for you.

> It should be pretty straightforward. I wrapped curl_multi_socket_action and
> curl_multi_socket_all, plus some constants.

I guess you only do this for testing purposes? Using select() for
curl_multi_socket() kind of defeats its purpose...

> 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)

0? is that the event bitmask? That can't be right.

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

And you have a callback setup to get the socket updates?

> 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.

Right, but I'd say that seems to indicate that you've lost track of the
sockets somehow!

> Now my question is, have there been any confirmed success of using
> curl_multi_socket interface on Win32?

I honestly can't recall if we have.

> - Programming curl_multi_socket in C/on Win32 (thus isolate
> potential python select issue)

Yes, that sounds clever.

> - Try the modification on Linux

Well, that would be a good idea if you're really sure that you're doing things
the right way.

-- 
  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2008-06-10