@@ -36,12 +36,14 @@ Please note that only Interactive plans can access sensor values and set the
3636system state; using the API with a Standard plan will be limited to retrieving
3737the current system state.
3838
39- Scaffolding
40- -----------
39+ Connection Pooling
40+ ------------------
4141
42- Installing ``simplipy `` also includes ``aiohttp ``, which is the engine that powers
43- the entire library. All interactions with ``simplipy `` start within an
44- ``aiohttp `` ``ClientSession ``:
42+ By default, the :meth: `API <simplipy.api.API> ` object creates a new connection to
43+ SimpliSafe™ with each coroutine. If you are calling a large number of coroutines (or
44+ merely want to squeeze out every second of runtime savings possible), an
45+ ``aiohttp ClientSession `` can be supplied when logging into the API (via credentials or
46+ token) to achieve connection pooling:
4547
4648.. code :: python
4749
@@ -53,10 +55,14 @@ the entire library. All interactions with ``simplipy`` start within an
5355
5456 async def main () -> None :
5557 """ Create the aiohttp session and run."""
56- async with ClientSession() as websession:
57- # YOUR CODE HERE
58+ async with ClientSession() as session:
59+ simplisafe = await API .login_via_credentials(
60+ " <EMAIL>" , " <PASSWORD>" , session = session
61+ )
5862
63+ # ...
5964
60- asyncio.get_event_loop().run_until_complete(main())
6165
62- Every example within this documentation assumes the use of the above scaffolding.
66+ asyncio.run(main())
67+
68+ Every example in this documentation uses this pattern.
0 commit comments