Skip to content
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

Fixed stuck BatchedSend comm #4128

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion distributed/batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def send(self, msg):
self.message_count += 1
self.buffer.append(msg)
# Avoid spurious wakeups if possible
if self.next_deadline is None:
if self.next_deadline is None or self.next_deadline < self.loop.time():
self.waker.set()

@gen.coroutine
Expand Down
17 changes: 17 additions & 0 deletions distributed/tests/test_batched.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,20 @@ async def test_serializers():

with pytest.raises(TimeoutError):
msg = await asyncio.wait_for(comm.read(), 0.1)


@pytest.mark.asyncio
async def test_missed_deadline():
async with EchoServer() as e:
comm = await connect(e.address)
b = BatchedSend(interval=10)
b.start(comm)

await asyncio.sleep(0.020)
# We've missed the deadline.
b.next_deadline = b.loop.time() - b.interval
b.send("hello")
b.send("world")
await asyncio.sleep(0.020)
assert len(b.buffer) == 0
await b.close()