Skip to content

Commit 3276bc6

Browse files
Merge pull request #2466 from domwhewell-sage/timeout_gitdumper
Add strategic timeouts to gitdumper
2 parents 33d808b + 4755aa5 commit 3276bc6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bbot/modules/gitdumper.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import regex as re
23
from pathlib import Path
34
from subprocess import CalledProcessError
@@ -122,7 +123,11 @@ async def handle_event(self, event):
122123
dir_listing = await self.directory_listing_enabled(repo_url)
123124
if dir_listing:
124125
urls = await self.recursive_dir_list(dir_listing)
125-
result = await self.download_files(urls, repo_folder)
126+
try:
127+
result = await self.download_files(urls, repo_folder)
128+
except asyncio.CancelledError:
129+
self.verbose(f"Cancellation requested while downloading files from {repo_url}")
130+
result = True
126131
else:
127132
result = await self.git_fuzz(repo_url, repo_folder)
128133
if result:
@@ -172,7 +177,10 @@ async def git_fuzz(self, repo_url, repo_folder):
172177
result = await self.download_files(url_list, repo_folder)
173178
if result:
174179
await self.download_current_branch(repo_url, repo_folder)
175-
await self.download_git_objects(repo_url, repo_folder)
180+
try:
181+
await self.download_git_objects(repo_url, repo_folder)
182+
except asyncio.CancelledError:
183+
self.verbose(f"Cancellation requested while downloading git objects from {repo_url}")
176184
await self.download_git_packs(repo_url, repo_folder)
177185
return True
178186
else:

0 commit comments

Comments
 (0)