Skip to content

Commit

Permalink
Stop main ui worker from freezing
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Nov 4, 2024
1 parent 4eedba4 commit b278920
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ def __init__(self):
def run(self):
while True:
if pending:
item_id = next(iter(pending)) # Get the first key
item = pending.pop(item_id)
token = get_account_token()
item_metadata = globals()[f"{item['item_service']}_get_{item['item_type']}_metadata"](token, item['item_id'])
self.add_item_to_download_list.emit(item, item_metadata)
continue
try:
item_id = next(iter(pending))
item = pending.pop(item_id)
token = get_account_token()
item_metadata = globals()[f"{item['item_service']}_get_{item['item_type']}_metadata"](token, item['item_id'])
self.add_item_to_download_list.emit(item, item_metadata)
continue
except Exception as e:
logger.error(f"Unknown Exception for {item}: {str(e)}")
pending[item_id] = item
else:
time.sleep(4)


class MainWindow(QMainWindow):

# Remove Later
Expand Down

0 comments on commit b278920

Please sign in to comment.