From 0bf876fb1526813249a22e77566535cb8aadaea9 Mon Sep 17 00:00:00 2001 From: meowmeowcat <68463158+meowmeowmeowcat@users.noreply.github.com> Date: Tue, 10 Aug 2021 00:54:11 +0800 Subject: [PATCH 1/3] bpo-44508: Document failure mode for loop.call_soon_threadsafe --- Doc/library/asyncio-eventloop.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 98ec65dde887c8..c1f831168a3b4f 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -214,7 +214,8 @@ Scheduling callbacks .. method:: loop.call_soon_threadsafe(callback, *args, context=None) A thread-safe variant of :meth:`call_soon`. Must be used to - schedule callbacks *from another thread*. + schedule callbacks *from another thread*. If the event loop has been + closed, :exc:`RuntimeError` is raised. See the :ref:`concurrency and multithreading ` section of the documentation. From 5bec1c80a10f0b6ab9e74b9aaa028cfa60c861e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 17 Aug 2021 23:51:09 +0200 Subject: [PATCH 2/3] Reword exception portion --- Doc/library/asyncio-eventloop.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index c1f831168a3b4f..7998b1fa79b84e 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -214,8 +214,11 @@ Scheduling callbacks .. method:: loop.call_soon_threadsafe(callback, *args, context=None) A thread-safe variant of :meth:`call_soon`. Must be used to - schedule callbacks *from another thread*. If the event loop has been - closed, :exc:`RuntimeError` is raised. + schedule callbacks *from another thread*. + + Raises :exc:`RuntimeError` if called on a loop that's been closed. + This can happen on a secondary thread when the main application is + shutting down. See the :ref:`concurrency and multithreading ` section of the documentation. From 4e95162ad19b88bed59ec6a71ffd4bc8bb1da5c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Wed, 18 Aug 2021 00:27:30 +0200 Subject: [PATCH 3/3] appease gods of whitespace --- Doc/library/asyncio-eventloop.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 7998b1fa79b84e..147fb2b9bf603d 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -215,7 +215,7 @@ Scheduling callbacks A thread-safe variant of :meth:`call_soon`. Must be used to schedule callbacks *from another thread*. - + Raises :exc:`RuntimeError` if called on a loop that's been closed. This can happen on a secondary thread when the main application is shutting down.