Skip to content

Commit

Permalink
GithubNotifications: fix blocking web call
Browse files Browse the repository at this point in the history
The API call can block causing the system to appear unresponsive.
Run the call in a thread instead.

Fixes #80
  • Loading branch information
elParaguayo committed Jul 21, 2022
1 parent 22d22ae commit 2a8ddcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2022-07-21: [BUGFIX] Fix blocking API calls in Snapcast and GithubNotification widgets
2022-07-07: [BUGFIX] Fix UPowerWidget not showing text on click when fontsize is None
2022-07-03: [PACKAGING] Use git versioning details
2022-07-03: [BUGFIX] Fix scaling on CurrentLayoutIcon and disable `use_mask=True` default
Expand Down
8 changes: 7 additions & 1 deletion qtile_extras/widget/githubnotifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,18 @@ def update(self):
logger.error("No access token provided.")
return

future = self.qtile.run_in_executor(self._get_data)
future.add_done_callback(self._read_data)

def _get_data(self):
headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {self.token}",
}
return requests.get(NOTIFICATIONS, headers=headers)

r = requests.get(NOTIFICATIONS, headers=headers)
def _read_data(self, reply):
r = reply.result()

if r.status_code != 200:
self.error = True
Expand Down

0 comments on commit 2a8ddcc

Please sign in to comment.