Skip to content

Commit 84b7602

Browse files
committed
BF: exit newsUpdate thread gracefully if no connection
1 parent 68e6f4a commit 84b7602

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

psychopy/app/connections/news.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919

2020
def getNewsItems(app=None):
2121
url = newsURL + "news_items.json"
22-
resp = requests.get(url)
22+
try:
23+
resp = requests.get(url, timeout=0.5)
24+
except requests.ConnectionError:
25+
return None
2326
if resp.status_code == 200:
2427
try:
2528
items = resp.json()
@@ -52,6 +55,8 @@ def showNews(app=None, checkPrev=True):
5255
break
5356
if not toShow:
5457
return 0
58+
else:
59+
return 0
5560

5661
dlg = wx.Dialog(None, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
5762
size=(800, 400))

0 commit comments

Comments
 (0)