How to cleanly stop a reactor?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- networking
Research direction
Start with the irccat example and the Reactor, server connection, callback handlers, and process_forever calls shown in the issue. Determine how a client can stop the reactor cleanly after sending its message while allowing synchronous code to continue, and document or expose an API whose completion can be verified without terminating a process.
Written by the indexing model from the issue text.
Description
I'm trying to write an asynchronous client that's just trying to connect, join a channel, send a message and then quit. I looked at irccat as an example, but I am left with a reactor working while I want the rest of my program to continue outside of that flow. My workaround is that I created a multiprocessing.Process that I then terminate:
import time
import logging
import multiprocessing
import irc.client
logging.basicConfig(level='DEBUG')
def notify_thread(msg):
client = irc.client.Reactor()
server = client.server()
server.connect('irc.freenode.net', 6667, 'hsldzat')
def on_connect(connection, event):
connection.join('##test3')
def on_join(connection, event):
connection.privmsg('##test3', msg)
connection.quit()
client.add_global_handler("welcome", on_connect)
client.add_global_handler("join", on_join)
client.process_forever()
def notify(msg):
t = multiprocessing.Process(target=notify_thread, args=(msg, ))
t.start()
time.sleep(60)
t.terminate()
while True:
for i in range(3):
notify('hello' + str(i+1))
Assuming that it's critical for my code to work synchronously and outside of the callback-based model, is there a cleaner way to use the API? Perhaps it would make sense to incorporate it into irccat example instead of doing sys.exit()?
- 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
-
cognition facet:consolidation memory ready size:S
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
proposal
Difficulty 1/5 Under an hour Newbie friendliness 68/100
j3ko/agent-plugins#29 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Judgment-Pack/judgment-pack-spec#335 ·
Maintainers usually reply within 1 day