Repository: praw-dev/praw
Pull request #1629 (2021-01-30 21:49:45)

Improve error message and documentation for asynchronous check and add change log entry for #1628
This PR catches things miss in #1628.

## References

* #1628


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 2247818f..75e1e224 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -16,6 +16,9 @@ Unreleased
   specify type of award, anonymity, and message when awarding a submission or comment.
 * Ability to specify subreddits by name using the `subreddits` parameter in
   :meth:`.Reddit.info`.
+* A check to see if PRAW is running in an asynchronous environment and will advise the
+  user to use `Async PRAW <https://asyncpraw.readthedocs.io>`_. This also adds a
+  configuration option to disable the check.
 
 **Changed**
 
diff --git a/docs/getting_started/configuration/options.rst b/docs/getting_started/configuration/options.rst
index 7078ea73..2a27ffb4 100644
--- a/docs/getting_started/configuration/options.rst
+++ b/docs/getting_started/configuration/options.rst
@@ -95,6 +95,10 @@ Miscellaneous Configuration Options
 
 These are options that do not belong in another category, but still play a part in PRAW.
 
+:check_for_async: When ``true``, check if PRAW is being ran in an asynchronous
+    environment whenever a request is made. If so, a warning will be logged recommending
+    the usage of `Async PRAW <https://asyncpraw.readthedocs.io/>`_. (default: ``true``)
+
 :ratelimit_seconds: Controls the maximum amount of seconds PRAW will capture ratelimits
     returned in JSON data. Because this can be as high as 10 minutes, only ratelimits of
     up to 5 seconds are captured and waited on by default. Should be a number
diff --git a/docs/getting_started/multiple_instances.rst b/docs/getting_started/multiple_instances.rst
index 6b0d8401..59e77421 100644
--- a/docs/getting_started/multiple_instances.rst
+++ b/docs/getting_started/multiple_instances.rst
@@ -24,9 +24,9 @@ features as PRAW.
 
 .. note::
 
-    By default, PRAW will check to see if it is in an asynchronous environment at the
-    initialization of :class:`.Reddit` and every time a network request is made. To
-    disable this check you can do:
+    By default, PRAW will check to see if it is in an asynchronous environment every
+    time a network request is made. To disable this check, set the ``check_for_async``
+    configuration option to ``false``. For example:
 
     .. code-block:: python
 
diff --git a/praw/reddit.py b/praw/reddit.py
index bbddfa5c..464f4728 100644
--- a/praw/reddit.py
+++ b/praw/reddit.py
@@ -359,7 +359,7 @@ class Reddit:
                 logger.warning(
                     "It appears that you are using PRAW in an asynchronous"
                     " environment.\nIt is strongly recommended to use Async PRAW:"
-                    " https://asyncpraw.readthedocs.io/en/latest/.\nSee"
+                    " https://asyncpraw.readthedocs.io.\nSee"
                     " https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments"
                     " for more info.\n",
                 )


Test patch:
diff --git a/tests/unit/test_reddit.py b/tests/unit/test_reddit.py
index 1731b221..e293b1ad 100644
--- a/tests/unit/test_reddit.py
+++ b/tests/unit/test_reddit.py
@@ -41,7 +41,7 @@ class TestReddit(UnitTest):
         assert log_record.levelname == "WARNING"
         assert log_record.message == (
             "It appears that you are using PRAW in an asynchronous environment.\nIt is"
-            " strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io/en/latest/."
+            " strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io."
             "\nSee https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments"
             " for more info.\n"
         )