Skip to content

Commit 0e65ee7

Browse files
committed
document usage of 'with' for the BaseAPI object
1 parent ae87e1a commit 0e65ee7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.rst

+9
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ The first thing you need to do is to connect with PuppetDB:
9797
>>> from pypuppetdb import connect
9898
>>> db = connect()
9999
100+
You can also use the `with` statement to enclose the work done on PuppetDB.
101+
This will ensure that all HTTP connections are closed explicitly when we're
102+
done:
103+
104+
.. code-block:: python
105+
106+
>>> with connect() as db:
107+
>>> # ..
108+
100109
Nodes
101110
-----
102111

docs/quickstart.rst

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ The first thing you need to do is to connect with PuppetDB:
1515
>>> from pypuppetdb import connect
1616
>>> db = connect()
1717
18+
You can also use the `with` statement to enclose the work done on PuppetDB.
19+
This will ensure that all HTTP connections are closed explicitly when we're
20+
done:
21+
22+
.. code-block:: python
23+
24+
>>> with connect() as db:
25+
>>> # ..
26+
1827
Nodes
1928
-----
2029

0 commit comments

Comments
 (0)