Skip to content

feature(core): implement core.sleep #2170

Description

@membphis

Use a small time interval (such as 1s) to complete a relatively long sleep behavior, so that the worker process can be shut down gracefully.

Here is the fake code(we may):

function sleep(sec)
    if sec <= 1 then
        ngx_sleep(sec)
        return
    end

    while true do
        if sec > 1 then
            ngx_sleep(1)
        end

        if exiting() then
            return
        end

        sec = sec - 1
        if sec < 1 then
            ngx_sleep(sec)
            return
        end
    end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions