Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Discord.py asyncio not working
-
My discord bot will not run on Pythonista, while the exact same code runs fine on my PC. It says I need a coroutine or future and while the type of on_ready() is class coroutine and I’ve decorated it with @asyncio.coroutine and added async to the function def, it won’t work and I still get a TypeError.
I couldn’t care less if my Token shows up, it’s useless if I can’t get the code to run. I’m going off of good faith here so let me know if any of you nerds can figure out what’s wrong ❤️🙏😁!
If you need to see any of the actual code in the file, please specify and I’ll post!
Thanks in advance!Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/Programming Practice Files/Bots/challongebots/PCSuccessfulTourney.py", line 148, in <module>
client.run(strongbot.token)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/discord/client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/asyncio/base_events.py", line 316, in run_until_complete
return future.result()
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/asyncio/futures.py", line 275, in result
raise self._exception
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/asyncio/tasks.py", line 238, in _step
result = next(coro)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/discord/client.py", line 490, in start
yield from self.login(*args, **kwargs)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/discord/client.py", line 416, in login
yield from getattr(self, 'login' + str(n))(*args, **kwargs)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/discord/client.py", line 346, in _login_1
data = yield from self.http.static_login(token, bot=is_bot)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/discord/http.py", line 258, in static_login
data = yield from self.request(Route('GET', '/users/@me'))
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/discord/http.py", line 137, in request
r = yield from self.session.request(method, url, **kwargs)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/aiohttp/client.py", line 366, in _request
timeout=timeout
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/aiohttp/connector.py", line 445, in connect
proto = await self._create_connection(req, traces, timeout)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/aiohttp/connector.py", line 757, in _create_connection
req, traces, timeout)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/aiohttp/connector.py", line 843, in _create_direct_connection
traces=traces), loop=self._loop)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/asyncio/tasks.py", line 643, in shield
inner = async(arg, loop=loop)
File "/private/var/mobile/Containers/Shared/AppGroup/F593CC7F-EBE7-4157-91D6-DF1EBDABA21A/Pythonista3/Documents/site-packages-3/asyncio/tasks.py", line 516, in async
raise TypeError('A Future or coroutine is required')
TypeError: A Future or coroutine is required -
Please share the code, as short a version as possible, and I will give it a try.
I trust you have looked at the other thread on Discord async problems?
-
okay....
first, please go into site-packages-3, and delete the asyncio folder. I suspect that async def is using builtin asyncio, but then import asyncio is using the wrong version...
-
@mikael thank you for tagging it here but alas, I could not find anything anywhere (even there) while scraping the web since I encountered this issue 5 days ago 😅.
-
@JonB I love you! Deleting asyncio from site-packages solved my problem with no side effects so far, and I’ve had to change nothing about the file that works on my laptop to run it on my phone (though I forgot if there are any libraries I needed to install between the two systems besides ‘pip install discord’ and ‘pip install pychal’
I’ll try to reset my Pythonista app in the future and make a guide for this kind of stuff once I get the free time but until then, you’ve helped free up a new world of Pythonista programming capabilities for me!
🙏 😆 🖥📲💯!
-
I was going to play with asyncio but didn't get far:
import asyncio
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/var/containers/Bundle/Application/C1B2B29C-77ED-496F-8E3F-47352515D93C/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/asyncio/init.py", line 22, in <module>
from .base_events import *
File "/var/containers/Bundle/Application/C1B2B29C-77ED-496F-8E3F-47352515D93C/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/asyncio/base_events.py", line 18, in <module>
import concurrent.futures
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/concurrent/futures/init.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/concurrent/futures/_base.py", line 381
raise exception_type, self._exception, self._traceback
^
SyntaxError: invalid syntax -
look closely at the traceback. notice the last one is coming from something in site-packages.
delete site-packages/concurrent.
-
Thank you!