Skip to content

Commit 6826810

Browse files
committed
Add a fallback for aiosmtpd < 1.4.3
1 parent 712224e commit 6826810

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_localserver/smtp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ def stop(self, timeout=None):
130130
# be called more than once safely
131131
# - It passes the timeout argument to Thread.join()
132132
if self.loop.is_running():
133-
self.loop.call_soon_threadsafe(self.cancel_tasks)
133+
try:
134+
self.loop.call_soon_threadsafe(self.cancel_tasks)
135+
except AttributeError:
136+
# for aiosmtpd < 1.4.3
137+
self.loop.call_soon_threadsafe(self._stop)
134138
if self._thread is not None:
135139
self._thread.join(timeout)
136140
self._thread = None

0 commit comments

Comments
 (0)