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

[tacoshack] Hourly Income #6

Open
cool-aid-man opened this issue Jun 4, 2023 · 3 comments
Open

[tacoshack] Hourly Income #6

cool-aid-man opened this issue Jun 4, 2023 · 3 comments

Comments

@cool-aid-man
Copy link
Contributor

Getting this error on the console on Shack's hourly income.

[2023-06-04 17:00:00] [ERROR] discord.ext.tasks: Unhandled exception in internal background task 'hourly_income'.

11 | Traceback (most recent call last):
12 | File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/tasks/__init__.py", line 239, in _loop
13 | await self.coro(*args, **kwargs)
14 | File "/home/ubuntu/data/starship_main/cogs/CogManager/cogs/tacoshack/tacoshack.py", line 163, in hourly_income
15 | await schedule.run_pending()
16 | File "/home/ubuntu/data/starship_main/cogs/Downloader/lib/aioschedule/__init__.py", line 544, in run_pending
17 | await default_scheduler.run_pending()
18 | File "/home/ubuntu/data/starship_main/cogs/Downloader/lib/aioschedule/__init__.py", line 111, in run_pending
19 | return await asyncio.wait(jobs, *args, **kwargs)
20 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 | File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait
22 | raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
23 | TypeError: Passing coroutines is forbidden, use tasks explicitly.
@jmesfo0
Copy link
Owner

jmesfo0 commented Jun 25, 2023

I think I have addressed this issue, can you run .cog update and tell me if it works?

I was reading:

As of Python 3.8 this leads to a depreciation warning and starting from Python 3.11 it is an error. The correct way to use asyncio.wait() is by passing tasks created from your coroutines. Use create_task() to create these tasks explicitly.

Sorry for my late response, I was moving to another part of the country and did not have my computer :)

@cool-aid-man
Copy link
Contributor Author

Hey James!
I hope everything went smoothly with the shift. And it's okay!

I updated the cog,
Got this error after I reloaded the cog,

[2023-06-25 18:11:39] [ERROR] discord.ext.tasks: Unhandled exception in internal background task 'hourly_income'.

13 | Traceback (most recent call last):
14 | File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/tasks/__init__.py", line 239, in _loop
15 | await self.coro(*args, **kwargs)
16 | File "/home/ubuntu/.local/share/Red-DiscordBot/data/dusky/cogs/CogManager/cogs/tacoshack/tacoshack.py", line 163, in hourly_income
17 | await asyncio.wait(schedule.run_pending())
18 | File "/usr/lib/python3.11/asyncio/tasks.py", line 406, in wait
19 | raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
20 | TypeError: expect a list of futures, not coroutine

[2023-06-25 18:13:40] [ERROR] asyncio: Task exception was never retrieved

4 | future: <Task finished name='Task-7877' coro=<Loop._loop() done, defined at /home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/tasks/__init__.py:200> exception=TypeError('expect a list of futures, not coroutine')>
5 | Traceback (most recent call last):
6 | File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/tasks/__init__.py", line 264, in _loop
7 | raise exc
8 | File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/tasks/__init__.py", line 239, in _loop
9 | await self.coro(*args, **kwargs)
10 | File "/home/ubuntu/.local/share/Red-DiscordBot/data/dusky/cogs/CogManager/cogs/tacoshack/tacoshack.py", line 163, in hourly_income
11 | await asyncio.wait(schedule.run_pending())
12 | File "/usr/lib/python3.11/asyncio/tasks.py", line 406, in wait
13 | raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
14 | TypeError: expect a list of futures, not coroutine

@getFran
Copy link

getFran commented Mar 5, 2024

For anyone who encounters this problem, I found a work around to this. The only downside is that you can't schedule to update the balance at an exact time, It will run after 3600 seconds (1 hour) since the last time it was executed.

You will need to comment (recommended) / remove the following lines in the tacoshack.py file:

9 | import aioschedule as schedule
158 | schedule.every().hour.at(":00").do(self.update_balance)
167 | schedule.clear()

Now, head to the following line:

161 | @tasks.loop(seconds=1)

There you have to specify in seconds how often do you want the payments to be made. (3600 = 1 hour recommended)

Once done all of above, reload the tacoshack cog and you are all set.

PD: To @jmesfo0, I know this isn't the best solution nor how you originally planned it, but it is the easiest way to get everything working without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants