Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: alex0375@gmail.com
To: rainbows-public@bogomips.org
Subject: Waiting for deferred actions to finish
Date: Mon, 9 Jan 2017 16:43:48 +0300	[thread overview]
Message-ID: <CAKwvcL-VH3we4qA1pkNAstTmWvqNA=Rir2N_YiWztV_qbaLQvA@mail.gmail.com> (raw)

Hello!

I would like the Rainbows! to wait for deferred actions to finish
before shutdown. The documentation says the following:

> QUIT - graceful shutdown, waits for workers to finish their current request before finishing. This currently does not wait for requests deferred to a separate thread when using EventMachine (when app.deferred?(env) => true)
>
> https://bogomips.org/rainbows/SIGNALS.html

I came up with the following solution:

after_fork do |_server, _worker|
  # Wait for all deferred actions to finish before killing worker.
  Rainbows.at_quit do
    loop do
      break if EventMachine.defers_finished?

      sleep 1
    end
  end
end

Am I missing something? Can this be a part of Rainbows?

Thanks!

             reply	other threads:[~2017-01-09 13:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 13:43 alex0375 [this message]
2017-01-09 19:43 ` Eric Wong
2017-01-09 19:45   ` [PATCH 1/2] tests: re-enable EventMachine tests, again Eric Wong
2017-01-09 19:45   ` [PATCH 2/2] eventmachine: wait for deferred actions to finish Eric Wong
2017-01-10  7:31   ` Waiting " alex0375

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKwvcL-VH3we4qA1pkNAstTmWvqNA=Rir2N_YiWztV_qbaLQvA@mail.gmail.com' \
    --to=alex0375@gmail.com \
    --cc=rainbows-public@bogomips.org \
    --subject='Re: Waiting for deferred actions to finish' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	../../rainbows.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).