Skip to content

Commit 669df62

Browse files
Closes #18873: Add a request timeout parameter to the RSS feed dashboard widget (#20004)
1 parent 9df0bdc commit 669df62

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

netbox/extras/dashboard/widgets.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class RSSFeedWidget(DashboardWidget):
309309
default_config = {
310310
'max_entries': 10,
311311
'cache_timeout': 3600, # seconds
312+
'request_timeout': 3, # seconds
312313
'requires_internet': True,
313314
}
314315
description = _('Embed an RSS feed from an external website.')
@@ -335,6 +336,12 @@ class ConfigForm(WidgetConfigForm):
335336
max_value=86400, # 24 hours
336337
help_text=_('How long to stored the cached content (in seconds)')
337338
)
339+
request_timeout = forms.IntegerField(
340+
min_value=1,
341+
max_value=60,
342+
required=False,
343+
help_text=_('Timeout value for fetching the feed (in seconds)')
344+
)
338345

339346
def render(self, request):
340347
return render_to_string(self.template_name, {
@@ -366,7 +373,7 @@ def get_feed(self):
366373
url=self.config['feed_url'],
367374
headers={'User-Agent': f'NetBox/{settings.RELEASE.version}'},
368375
proxies=resolve_proxies(url=self.config['feed_url'], context={'client': self}),
369-
timeout=3
376+
timeout=self.config.get('request_timeout', 3),
370377
)
371378
response.raise_for_status()
372379
except requests.exceptions.RequestException as e:

0 commit comments

Comments
 (0)