Skip to content

Commit f23f323

Browse files
committed
Graceful shutdown?
1 parent 212e708 commit f23f323

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/async/websocket/adapters/http.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ def self.open(request, headers: [], protocols: [], handler: Connection, extensio
4040

4141
yield connection
4242

43-
connection.close unless connection.closed?
43+
connection.send_close
44+
until connection.closed?
45+
connection.read_frame
46+
end
47+
ensure
48+
stream.close
4449
end
4550

4651
# Once we get to this point, we no longer need to hold on to the request:

lib/async/websocket/client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def self.connect(endpoint, *arguments, **options, &block)
6262

6363
begin
6464
yield connection
65+
66+
connection.send_close
67+
until connection.closed?
68+
connection.read_frame
69+
end
6570
ensure
6671
connection.close
6772
client.close

0 commit comments

Comments
 (0)