> Hi Roberto,what do you think about this:
>
> in main loop:
> cl = my_http_client()
> # send returns without blocking
> uwsgi.send( cl.client, data, read_callback )
> uwsgi.wait_fd_read( cl.client, timeout, write_callback )
> # yield returns core and callback
> (uwsgi_core, callback) = yield ''
> callback()
>
> my_http_client:
> def __init__(self):
> self.client = uwsgi.async_connect('74.125.232.115:80')
> def read_callback(self)
> buf = uwsgi.recv(client, 1024)
>
> def write_callback(self)
> ...
>
> ####################
> with this kind of api it is also possible to write code like this:
>
> in main loop:
> client = uwsgi.async_connect('74.125.232.115:80')
> uwsgi.send( cl.client, data, partial(http_proto.write_callback, client)
> )
> uwsgi.wait_fd_read( cl.client, timeout,
> partial(http_proto.read_callback, client) )
> (uwsgi_core, callback) = yield ''
> # callback already curried and will be called with fd argument
> callback()
>
> http_proto:
> def read_callback(self, fd)
> buf = uwsgi.recv(fd, 1024)
>
> def write_callback(self, fd)
> ...
>
>
> by partial call i mean here curry pattern from functools
>
I like the callback approach, i will probably need to tweak some api
function but it should be easy.
Probably i should even add a way to avoid re-registering descriptor after
each event.
--
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi