Skip to content

Commit 54e1a34

Browse files
docs(readme): example snippet for client context manager (#2280)
1 parent 0991241 commit 54e1a34

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ client.with_options(http_client=DefaultHttpxClient(...))
375375

376376
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
377377

378+
```py
379+
from cloudflare import Cloudflare
380+
381+
with Cloudflare() as client:
382+
# make requests here
383+
...
384+
385+
# HTTP client is now closed
386+
```
387+
378388
## Semantic versioning
379389

380390
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

0 commit comments

Comments
 (0)