set_keepalive resulting into "irc.client.ServerNotConnectedError: Not connected."
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- networking
Research direction
Read irc/client.py around ServerConnection.set_keepalive(), Reactor.process_once(), the scheduler callback, and send_raw(); reproduce the traceback with multiple connections and then disconnect one. Done means processing the reactor after a connection is disconnected no longer attempts a keepalive that raises ServerNotConnectedError.
Written by the indexing model from the issue text.
Description
I'm developing a Relay Bot for Discord + IRC. Its logic is it creates a new ServerConnection object for each Discord user.
It all works fine, untill i recently made every new connection use the set_keepalive() function.
When i call quit() on a ServerConnection object sortly after i get this error.
File "/home/orfeasgr/NewRelayTest/classcon.py", line 48, in startloop
reactor.process_once(0.2)
File "/home/orfeasgr/.local/lib/python3.7/site-packages/irc/client.py", line 830, in process_once
self.process_timeout()
File "/home/orfeasgr/.local/lib/python3.7/site-packages/irc/client.py", line 800, in process_timeout
self.scheduler.run_pending()
File "/home/orfeasgr/.local/lib/python3.7/site-packages/tempora/schedule.py", line 185, in run_pending
self.run(command)
File "/home/orfeasgr/.local/lib/python3.7/site-packages/tempora/schedule.py", line 203, in run
command.target()
File "/home/orfeasgr/.local/lib/python3.7/site-packages/irc/client.py", line 556, in ping
self.send_items('PING', target, target2)
File "/home/orfeasgr/.local/lib/python3.7/site-packages/irc/client.py", line 595, in send_items
self.send_raw(' '.join(filter(None, items)))
File "/home/orfeasgr/.local/lib/python3.7/site-packages/irc/client.py", line 603, in send_raw
raise ServerNotConnectedError("Not connected.")
irc.client.ServerNotConnectedError: Not connected.
At first i thought it was me using quit() instead of disconnect() but changing that still raised the same error.
Then i wondered if process.once() could be causing the error, but then i realised that would have happened a lot earlier, so i tried to remove the set_keepalive call, which was a much more recent addition to my code and after disconnecting a connection the error didn't happen.
So i came to the conclusion that set_keepalive is apparently called when process_once() is called(?) and that it tries to send a PING command to the server for all ServerConnection objects and that in turn raises the Not Connected error, when any of the objects are not connected.
I assume somewhere along the way the connection object is not removed properly from the Reactor object's connections list when a ServerConnection object is disconnected.
EDIT: I realised i didn't really explain how i'm using the library. My code basically creates a Reactor object and then, when needed, makes a new ServerConnection object, and when needed can disconnect one of those. That's when set_keepalive() ultimately leaded to the error being raised.
- Dominant language
- Python
- Stars
- 422
- Forks
- 91
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jaraco/irc
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
docs pydanty:is-working
Difficulty 1/5 Under an hour Newbie friendliness 88/100
pydantic/pydantic-ai#13563 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NCATSTranslator/Babel#1204 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
alltheplaces/alltheplaces#20570 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
sio2project/oioioi#981 · 1 reaction ·
Maintainers usually reply within 1 day