Skip to content

Commit d1b3935

Browse files
committed
prevent hitting ARG_MAX limit
1 parent 73b7bbf commit d1b3935

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

library/multidb/allocate_torrents.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -242,23 +242,25 @@ def allocate_torrents():
242242
ssh.connect(d["host"])
243243
setattr(ssh, "host", d["host"])
244244

245-
remote_processes.cmd(
246-
ssh,
247-
"python3",
248-
"-m",
249-
"library",
250-
"torrents-start",
251-
*argparse_utils.forward_arggroups(args, arggroups.torrents_start),
252-
*argparse_utils.forward_arggroups(args, arggroups.qBittorrent),
253-
*argparse_utils.forward_arggroups(
254-
args,
255-
arggroups.qBittorrent_paths,
256-
download_drive=d["mountpoint"],
257-
),
258-
*torrent_files,
259-
local_files=torrent_files,
260-
# cwd="lb", # debug
261-
)
245+
torrent_files_chunks = iterables.chunks(torrent_files, 128)
246+
for torrent_files_chunk in torrent_files_chunks:
247+
remote_processes.cmd(
248+
ssh,
249+
"python3",
250+
"-m",
251+
"library",
252+
"torrents-start",
253+
*argparse_utils.forward_arggroups(args, arggroups.torrents_start),
254+
*argparse_utils.forward_arggroups(args, arggroups.qBittorrent),
255+
*argparse_utils.forward_arggroups(
256+
args,
257+
arggroups.qBittorrent_paths,
258+
download_drive=d["mountpoint"],
259+
),
260+
*torrent_files_chunk,
261+
local_files=torrent_files_chunk,
262+
# cwd="lb", # debug
263+
)
262264

263265
if args.delete_torrent:
264266
for path in torrent_files:

library/utils/arggroups.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,9 @@ def qBittorrent_torrents(parent_parser):
20312031
action="append",
20322032
help="""Include torrents constrained by average file sizes (uses the same syntax as fd-find)""",
20332033
)
2034-
parser.add_argument("--file-count", "--files", action="append", help="Include torrents constrained by total file counts")
2034+
parser.add_argument(
2035+
"--file-count", "--files", action="append", help="Include torrents constrained by total file counts"
2036+
)
20352037
parser.add_argument("--seeders", action="append", help="Include torrents with N seeders")
20362038
parser.add_argument("--leechers", action="append", help="Include torrents with N leechers")
20372039
parser.add_argument("--time-added", action="append", help="Include torrents with N time since added")
@@ -2069,9 +2071,7 @@ def qBittorrent_torrents(parent_parser):
20692071
help="Include uploading torrents",
20702072
)
20712073

2072-
parser.add_argument(
2073-
"--file-counts", action="store_true", help="Include file counts column (a bit slow)"
2074-
)
2074+
parser.add_argument("--file-counts", action="store_true", help="Include file counts column (a bit slow)")
20752075
parser.add_argument("--trackers", action="store_true", help="Include tracker column")
20762076
parser.add_argument("--status", "--state", action="store_true", help="Include state column")
20772077
parser.add_argument("--paths", action="store_true", help="Include downloading/seeding path columns")

library/utils/remote_processes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def print_std(s, is_success):
5656
returncode = stdout.channel.recv_exit_status()
5757

5858
host = getattr(ssh, "host", None)
59-
if host:
59+
if host: # for logging purposes
6060
command = " ".join(["ssh", host, command])
6161

6262
r = subprocess.CompletedProcess(command, returncode, stdout.read().decode(), stderr.read().decode())
@@ -80,6 +80,8 @@ def print_std(s, is_success):
8080
log.warning("[%s] exited %s", command, r.returncode)
8181

8282
if strict:
83+
if error_verbosity <= 1:
84+
log.error("[%s] exited %s", command, r.returncode)
8385
r.check_returncode()
8486

8587
return r

0 commit comments

Comments
 (0)