-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
webhook: fix error on reconnect #72
Conversation
The bot runs plugin `shutdown`s on disconnect from the IRC server. While this method stops serving requests it doesn't actually close the socket; the restarted webserver cannot then bind to the same host/port in order to listen+serve requests. This results in a `OSError: [Errno 98] Address already in use`. To avoid this, the server needs to be closed after `shutdown`. As of this commit, the fix is valid for all Python>=2.7,>=3.5.
FYI, you can emulate disconnects like those leading to #70 by forwarding a local port to an IRC server (or bouncer). If you connect via SSL, you will likely have to set Example: ## Set the bot to connect to localhost:6665
## (the bot will start the shutdown-wait-reconnect cycle each time you stop socat)
$ socat TCP4-LISTEN:6665,fork,reuseaddr TCP4:chat.freenode.net:6665
^C
$ socat TCP4-LISTEN:6665,fork,reuseaddr TCP4:chat.freenode.net:6665
^C |
Why Python >=3.5 and not >=3.3? While not a hard requirement, it's ideal for a Sopel 7 plugin to support all Python versions that Sopel itself runs on—and until Sopel 8.0, that's 2.7.x and 3.3+. (Before writing that massive comment on #70, I swear I had two questions about this PR, but I can only think of the one now. Sorry in advance if I come back and double-post because I suddenly remembered what question 2 was going to be! 😅) |
Ah yes. That was just a case of my being more verbose than necessary. Technically, `server_close` was introduced in 2.6, and so Python itself allows this "fix" for any later versions (including all 3.x) to date. I just wrote it that way since Py<2.7 and <3.5 are EOL'd from the Python end.
(edit: I mean yeah, 2 is also EOL… so yeah, idk what I was thinking hehe)
So to rephrase: the fix works for all currently supported versions of Sopel… I'll leave it at that 😌
…On August 8, 2020 2:19:56 AM EDT, dgw ***@***.***> wrote:
Why Python >=3.5 and not >=3.3? While not a _hard_ requirement, it's
ideal for a Sopel 7 plugin to support all Python versions that Sopel
itself runs on—and until Sopel 8.0, that's 2.7.x and 3.3+.>
>
(Before writing that massive comment on #70, I swear I had _two_
questions about this PR, but I can only think of the one now. Sorry in
advance if I come back and double-post because I suddenly remembered
what question 2 was going to be! 😅)>
>
-- >
You are receiving this because you authored the thread.>
Reply to this email directly or view it on GitHub:>
#72 (comment)
|
Totally missed labeling/milestoning this before. I think it's about time to push for 0.4.0 soon, with all its nice little tweaks. |
The bot runs plugin
shutdown
s on disconnect from the IRC server. Whilethis method stops serving requests it doesn't actually close the socket;
thus, the "restarted" webserver cannot bind to the same host/port in order
to listen+serve requests. This results in a
OSError: [Errno 98] Address already in use
. The server needs to be closed aftershutdown
.edit: As of this commit, the fix is valid for all supported Python
>=2.7,>=3.5.