Skip to content

Commit

Permalink
Update sleep example for testing graceful shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 28, 2024
1 parent 87f1062 commit 58e7446
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions examples/sleep/config.ru
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@

require 'async'

LIMIT = Async::Semaphore.new(8)

run do
LIMIT.acquire do
sleep(1)
body = Async::HTTP::Body::Writable.new

Async do
30.times do
body.write "(#{Time.now}) Hello World #{Process.pid}\n"
sleep 1
end
ensure
body.close
end

[200, {}, ['Hello World']]
[200, {}, body]
end

# Run the server:
Expand Down

0 comments on commit 58e7446

Please sign in to comment.