-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: allow ngx.sleep to be used blockingly in non-yieldable phases #1759
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4720,14 +4720,17 @@ Since <code>v0.8.3</code> this function returns <code>1</code> on success, or re | |
|
||
'''syntax:''' ''ngx.sleep(seconds)'' | ||
|
||
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*, ngx.timer.*, ssl_certificate_by_lua*, ssl_session_fetch_by_lua*'' | ||
'''context:''' ''init_by_lua*, init_worker_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*, balancer_by_lua*, ssl_certificate_by_lua*, ssl_session_fetch_by_lua*, ssl_session_store_by_lua*, exit_worker_by_lua*'' | ||
|
||
Sleeps for the specified seconds without blocking. One can specify time resolution up to 0.001 seconds (i.e., one millisecond). | ||
Sleeps for the specified seconds without blocking in yieldable phases or blockingly in other phases. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we'd better clarify the blockingly phases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and we need to highlight it's not recommended to use it in the non-yieldable phase since it will block the whole nginx worker process. |
||
One can specify time resolution up to 0.001 seconds (i.e., one millisecond). | ||
|
||
Behind the scene, this method makes use of the Nginx timers. | ||
|
||
Since the <code>0.7.20</code> release, The <code>0</code> time argument can also be specified. | ||
|
||
Since the <code>FIXME</code> release, this method can be used in non-yieldable phases blockingly. | ||
|
||
This method was introduced in the <code>0.5.0rc30</code> release. | ||
|
||
== ngx.escape_uri == | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not safe to use blocking sleeps in certain contexts like
init_worker_by_lua*
,set_by_lua*
,header_filter_by_lua*
, and etc.I'm fine with enabling it in contexts where blocking operations do not matter, like in
init_by_lua*
andexit_worker_by_lua*
. Otherwise it's too dangerous.