Hello!
On Wed, Jan 6, 2016 at 6:41 PM, Russell Sullivan wrote:
> My question is since the documentation
> (https://github.com/openresty/lua-nginx-module#ngxsleep) states: "Behind the
> scene, this method makes use of the Nginx timers." is there any reason
> ngx.sleep() can not be enabled in the init_worker_by_lua context?
>
The reason is simply that ngx.sleep() yields while nginx's init worker
process callback does not support yielding. I think we can just use
the blocking approach there since it doesn't matter to block the OS
thread in that very context (similar to the init_by_lua* context).
Following this reasoning, we could emulate ngx.sleep and even
cosockets in the contexts of init_by_lua* and init_worker_by_lua*.
Patches welcome, volunteers welcome :)
Regards,
-agentzh