Il giorno 29/set/2011, alle ore 04:37, Valentin V. Bartenev ha scritto:

> On Wednesday 28 September 2011 21:42:18 Valentin V. Bartenev wrote:
>> Looks like, there remains one thing to do: detach a file reading task from
>> async application into a special separate uwsgi service, where the read
>> will be blocking and call it through async_send_message.
> 
> Now, I tried, and it doesn't work:
> 
> import os
> 
> def fileHandler(filename, modifier2):
>       fd = os.open(filename, os.O_RDONLY)
>       try:
>               while True:
>                       buf = os.read(fd, 4096) #32768)
>                       if buf:
>                               yield buf
>                       else:
>                               raise StopIteration
>       finally:
>               fd.close()
> 
> I'm getting this:
> [uWSGI DEBUG] uwsgi payload size: 91 (0x5B) modifier1: 32 modifier2: 0
> -- unavailable modifier requested: 32 --
> 
> when I call from another uwsgi instance:
> uwsgi.async_send_message(fl_fd, 0, 32, path)
> 
> Am I doing something wrong, or handling 32's modifier just haven't been 
> implemented yet?
> 
> wbr, Valentin V. Bartenev
> 

All of the modifier (except 0 and 30) referring to python, lost sense when it 
became multi-language.

By the way, the uwsgi.suspend() loop (until all data are available) is not too 
much expensive if you are not under heavy I/O.

Obviously the only sane way to bypass this is using posix aio. My idea is 
adding two new function api:

# create a memory area for the data (cold be used in other areas too)
bucket = uwsgi.alloc(size)
# issue an aio_read and suspend if data are not ready
ready = uwsgi.async_aio_read(fd, bucket)
if not ready:
    uwsgi.suspend()
# now bucket contains data
print bucket


--
Roberto De Ioris
http://unbit.it
JID: [email protected]

_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to