Skip to content

Commit 8bbf70c

Browse files
committed
README section for iRODSSession instance usage
1 parent d3cbda0 commit 8bbf70c

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,39 @@ Uninstalling
4141
Establishing a (secure) connection
4242
----------------------------------
4343

44-
One way of starting a session is to pass iRODS credentials as keyword
44+
An `iRODSSession` instance is the interface object through which iRODS server
45+
APIs can be invoked. One way to create the session object, assuming one has
46+
already successfully set up an client environment via `iinit`, is by using a
47+
simple `make_session` call:
48+
49+
```python
50+
from irods.helpers import make_session
51+
sess1 = make_session()
52+
53+
# Possible patterns include:
54+
# 1. keeping a ready reference to the session.
55+
56+
sess1.collections.get(f'/tempZone/home/{session.username}')
57+
# (... Further instances of calls to the server through sess1 may follow.)
58+
59+
# or:
60+
# 2. using the session object with a context manager.
61+
62+
with make_session() as sess2:
63+
my_user = sess2.users.get(ses.username)
64+
# Here, we can have other statements using sess2, and at end
65+
# of code block, sess2.cleanup() is implicitly called.
66+
67+
# sess1 retains an idle but reusable connection whereas sess2 does not; i.e.
68+
# sess1.pool.idle has length 1, and sess2.pool.idle is an empty set.
69+
# However, both sessions are equally open for further server interactions.
70+
```
71+
72+
Of course, we should be careful how many still-connected `iRODSSession` objects we retain
73+
references to in an application, as having more of them than the system can support
74+
database connections for can result in spurious failure of iRODS client connections.
75+
76+
Another way of starting a session is to pass iRODS credentials as keyword
4577
arguments:
4678

4779
```python

0 commit comments

Comments
 (0)