Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors in scheduled tasks #6

Open
zsarge opened this issue Oct 4, 2024 · 1 comment
Open

Handle errors in scheduled tasks #6

zsarge opened this issue Oct 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@zsarge
Copy link
Member

zsarge commented Oct 4, 2024

I think when this function ran:

@tasks.loop(time=NOON)
async def every_day(self):
self.log.debug("automatic trigger!")
await self.post_approved_submissions()

I got this error:

2024-10-02T16:00:09 UTC discord.ext.tasks [ERROR] Unhandled exception in internal background task 'every_day'.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/instagrapi/mixins/private.py", line 359, in _send_private_request
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/accounts/login/

During handling of the above exception, another exception occurred:

but then the function never ran again. So, we should probably handle that better

@zsarge zsarge added the bug Something isn't working label Oct 4, 2024
@zsarge
Copy link
Member Author

zsarge commented Oct 4, 2024

We probably want something like:

from requests.exceptions import HTTPError
# ...
try:
     self.log.debug("automatic trigger!") 
     await self.post_approved_submissions() 
except HTTPError:
    # error 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant