summaryrefslogtreecommitdiff
path: root/docs/api-usage.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api-usage.rst')
-rw-r--r--docs/api-usage.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/api-usage.rst b/docs/api-usage.rst
index 3704591..5816b6d 100644
--- a/docs/api-usage.rst
+++ b/docs/api-usage.rst
@@ -274,6 +274,23 @@ HTTP requests to the Gitlab servers.
You can provide your own ``Session`` object with custom configuration when
you create a ``Gitlab`` object.
+Context manager
+---------------
+
+You can use ``Gitlab`` objects as context managers. This makes sure that the
+``requests.Session`` object associated with a ``Gitlab`` instance is always
+properly closed when you exit a ``with`` block:
+
+.. code-block:: python
+
+ with gitlab.Gitlab(host, token) as gl:
+ gl.projects.list()
+
+.. warning::
+
+ The context manager will also close the custom ``Session`` object you might
+ have used to build a ``Gitlab`` instance.
+
Proxy configuration
-------------------