Skip to content
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
4 changes: 4 additions & 0 deletions Lib/asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ def recv(self, buffer_size):
raise

def close(self):
if self.closing:
return
self.closing = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this change should be documented in asyncore documentation using a ".. versionchanged:: 3.7" markup.


self.connected = False
self.accepting = False
self.connecting = False
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ def test_strerror(self):
err = asyncore._strerror(-1)
self.assertTrue(err != "")

def test_close(self):
d = asyncore.dispatcher()
d.close()
self.assertTrue(d.closing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a sec: I would check d.closing is False before close().


# calling close twice should not fail
d.close()


class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
def readable(self):
Expand Down