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

-- 
--------------------------------------------
Турнаев Евгений Викторович
+7 906 875 09 43
--------------------------------------------
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to