8000 IO::Generic#wait: fix call to Wrapper#wait_any (#76) · socketry/async-io@3238706 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Commit 3238706

Browse files
authored
IO::Generic#wait: fix call to Wrapper#wait_any (#76)
1 parent 23a5167 commit 3238706

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/async/io/generic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def wait(timeout = self.timeout, mode = :read)
169169
when :write
170170
wait_writable(timeout)
171171
else
172-
wait_any(:rw, timeout)
172+
wait_any(timeout)
173173
end
174174
rescue TimeoutError
175175
return nil

spec/async/io/generic_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,32 @@
7070

7171
[reader, writer].each(&:wait)
7272
end
73+
74+
it "can wait for anything" do
75+
reader = reactor.async do |task|
76+
duration = Async::Clock.measure do
77+
input.wait(1, nil)
78+
end
79+
80+
expect(duration).to be >= wait_duration
81+
expect(input.read(1024)).to be == message
82+
83+
input.close
84+
end
85+
86+
writer = reactor.async do |task|
87+
duration = Async::Clock.measure do
88+
output.wait(1, :write)
89+
end
90+
91+
task.sleep(wait_duration)
92+
93+
output.write(message)
94+
output.close
95+
end
96+
97+
[reader, writer].each(&:wait)
98+
end
7399

74100
it "can return nil when timeout is exceeded" do
75101
reader = reactor.async do |task|

0 commit comments

Comments
 (0)
0