Skip to content

Commit 17044a3

Browse files
committed
doc: filter_functions
1 parent e9d9800 commit 17044a3

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

irods/parallel.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727

2828
class FILTER_FUNCTIONS:
29+
"""The members of this class are free functions designed to be passed to
30+
the "filter_function" parameter of the abort_parallel_transfers function.
31+
"""
2932
foreground = staticmethod(lambda item: isinstance(item[1], tuple))
3033
background = staticmethod(lambda item: not isinstance(item[1], tuple))
3134

@@ -34,22 +37,34 @@ def abort_parallel_transfers(
3437
dry_run=False, filter_function=None, transform=weakref.WeakKeyDictionary
3538
):
3639
"""
37-
If no explicit arguments are given, all ongoing parallel puts and gets are cancelled
38-
as soon as possible. The corresponding threads are signalled to exit by calling the
39-
quit() method on their corresponding transfer-manager objects.
40+
If no explicit arguments are given, all ongoing parallel puts and gets are
41+
cancelled as soon as possible. The corresponding threads are signalled to
42+
exit by calling the quit() method on their corresponding transfer-manager
43+
objects.
44+
45+
Setting dry_run=True results in no such cancellation being performed,
46+
although a dict object will be computed for the return value containing,
47+
as its keys, the transfer-manager objects that would have been so affected.
48+
49+
filter_function is usually left to its default value of None. By applying
50+
a member of the FILTER_FUNCTIONS class, the caller may specify which
51+
transfer-managers are affected and/or reflected in the return value:
4052
41-
Setting dry_run=True results in no such cancellation being performed, although a dict object
42-
will be computed for the return value containing, as its keys, the transfer-manager objects that
43-
would have been so affected.
53+
FILTER_FUNCTIONS.foreground for example limits its scope to instances
54+
of session.data_object.put() and session.data_object.get() that are
55+
running synchronously. These calls block within the thread(s) that
56+
are calling them.
4457
45-
filter_function is usually left to its default value of None. Otherwise the effect will be to
46-
limit which transfers are to be aborted (or simply returned, if dry_run=True).
58+
FILTER_FUNCTIONS.background limits its scope to transfers started by
59+
calls to io_main() which used Oper.NONBLOCKING to spawn the put or
60+
get operation in the background.
4761
4862
transform defaults to a dictionary type with weak keys, since
49-
allowing strong references to transfer manager objects may artificially increase lifetimes of
50-
threads and other objects unnecessarily and complicate troubleshooting by altering library
51-
behavior. Consider using transform=len if all that is desired is to check how many transfers
52-
were cancelled.
63+
allowing strong references to transfer-manager objects may artificially
64+
increase lifetimes of threads and other objects unnecessarily and
65+
complicate troubleshooting by altering library behavior. Consider using
66+
transform=len if all that is desired is to check how many parallel
67+
transfers exist in total, at the time.
5368
"""
5469
mgrs = dict(filter(filter_function, transfer_managers.items()))
5570
if not dry_run:

0 commit comments

Comments
 (0)