-
-
Notifications
You must be signed in to change notification settings - Fork 409
bot, irc: IRC backend using asyncio #2256
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
Conversation
dgw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually made it through all the code, no thanks to Refined GitHub messing up my Split View (so I disabled the extension). Along the way I ran into a surprisingly low number of "WTF" moments (but don't worry, some did still happen).
My favorite thing about this might be that there's only one backend class now, instead of separate SSL/non-SSL classes. That means the bot doesn't have to dynamically choose a class to use at runtime. Apparently there was no compelling technical reason to build it that way (even if the forced polymorphism was neat just because you don't get to do things like that very often).
ctrl+c is working fine as far as I can tell, even tho the sequence is a bit complicated if you try to interrupt the bot at the startup sequence (servers tend to wait quite some time before replying to a
QUITcommand and closing the connection)
I've seen "problems" like this with the current implementation too, so don't worry about it. You're maintaining feature parity. :P
- I know it's possible but I haven't tried yet to run every single rule handlers into an asyncio task, trough asyncio.to_thread, and making
bot.on_messagea coroutine. That would involve a lot of change, while being 100% backward compatible with the current plugins & rules system. The end goal? To allow plugin to defineasyncplugin callables 😎
This is a good future goal. And it must be a future goal until we are ready to drop support for Python <=3.8, because asyncio.to_thread() isn't available until Python 3.9.
Hm... yes, you're right about |
|
Then it depends on whether you want to write the code twice, or wait until you can use the shortcut and write it only once. :P |
half-duplex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of abandoning the CNAME stuff. I don't like mucking with things like hostname verification, and it was introduced specifically for Twitch, where it's easily worked around by updating configs to point where the CNAME points.
ℹ️ This drops do_handshake_on_connect=False and suppress_ragged_eofs=True, introduced in 614abe1. asyncio should handle the first, and the second is the default.
I haven't played with this, since I need the other TLS changes from my PR, which I don't want to redo until this one is merged.
1a105e5 to
9830e11
Compare
dgw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of IRC chatter to clear up one logic-related question about CA certs, but we are probably going to remove that feature so I'm not bothered about it any more. Just one line note to save some of Exi's sanity during squash.
39184fa to
7dba103
Compare

Description
TL;DR: Tin. Close #1414.
Wouhou! This is it, that's the big PR for Sopel 8 that replaces the backend made with the now deprecated
asynchat(andasyncore) module by a backend made withasyncio—and it wasn't easy. It might be complicated to review this, even more with all the added stuffs that feel unnecessary (like a heavy dose of type annotation).I've tested it myself on two networks: Libera (with SSL on), and a private network (without SSL), and it all worked fine, ping timeout was handled properly, server timeout as well, ctrl+c is working fine as far as I can tell, even tho the sequence is a bit complicated if you try to interrupt the bot at the startup sequence (servers tend to wait quite some time before replying to a
QUITcommand and closing the connection).So what's in the box?
AsyncioBackendAbstractBackend.runto the__init__ofAsyncioBackendasyncio's high level API is used when possible, instead of working with the low-level API; this means that I didn't dive into Protocol, Transport, Socket, etc. and I decided to use theStreamReaderandStreamWriterobjectasyncio.Taskandasyncio.TimerHandlemanagement involved (mostly for thread-safety and for timeout management)AbstractBotABC class andAbstractIRCBackendhave been created or moved accordinglystartcommand, so I went maybe a bit too ballistic on that one—but given it now runs anEventLoop... who knows?What's missing?
on_irc_errorandon_errorcallbacks are used (when/how)bot.on_messagea coroutine. That would involve a lot of change, while being 100% backward compatible with the current plugins & rules system. The end goal? To allow plugin to defineasyncplugin callables 😎Checklist
make qa(runsmake qualityandmake test)