-
Notifications
You must be signed in to change notification settings - Fork 23
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
Example fails to run on python 3.10 #60
Comments
Thanks for opening an issue, sorry this is failing (and for so long!) I'll get started on a fix to remove the loop parameter and reference, this will be a major version bump. |
Thank you for taking a look. I knew that there might be some breakages by playing with 3.10 this early and just wanted to let you know. |
Hey @numberoverzero! First of all, let me say thanks, your project is so cool, I'm a big fan of this type of methodology (keep it simple and consistent). The mode of injecting events with decorators is just perfect, you see, FastAPI uses it, too the mode of detecting sync and async and call events with create_task for beginners is nice(would be nice to have a config to allow just await and keep to the user the control of background tasks with create_task). ATM in the scene, no other project is using coroutines by default, and really don't understand why. I really wait to your future releases :) Here is my grain of sand to make it work quickly in Python 3.10: Wrap the Client class with this: class Python310Client(Client):
def __init__(self, host: str, port: int, *, encoding: str = "utf-8", ssl: bool = True, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
"""Fix 3.10 error"""
super().__init__(host, port, encoding=encoding, ssl=ssl, loop=loop)
self._events = collections.defaultdict(lambda: asyncio.Event()) And for the connect event(also any wait call), remove the loop parameter: @bot.on('client_connect')
async def connect(**kwargs):
bot.send('NICK', nick=nick)
bot.send('USER', user=nick, realname=nick)
# Don't try to join channels until the server has
# sent the MOTD, or signaled that there's no MOTD.
done, pending = await asyncio.wait(
[bot.wait('RPL_ENDOFMOTD'),
bot.wait('ERR_NOMOTD')],
return_when=asyncio.FIRST_COMPLETED
)
# Cancel whichever waiter's event didn't come in.
for future in pending:
future.cancel()
bot.send('join', channel=channel) |
It appears that the asyncio API has changed in python 3.10, causing Bottom to exception.
The text was updated successfully, but these errors were encountered: