IRC bot threading dilemma

B

bakermi

Hello,

I have coded an IRC bot in Python. Each inbound packet is parsed, and
once the bot decides whether it is a command directed at the bot or
not, it will either
discard the packet or make a function call to an access control
checker function. If the invoking user is found to have sufficient
access to run this command, another function call is made. This
function call depends on what command the user in question has
invoked.

Try to imagine making one of these functions send out a WHOIS query to
the server, and wait for the burst of WHOIS-response packets from it.
How would this function wait? Yes, I know, I am going to have to
create another thread to loop while it waits for this reply packet.
The problem is, I can't simply tell my command function to loop until
the "waiter thread" raises a flag to say that it has received the
packet. During this looping time, program flow would be stuck here,
thus preventing the bot from replying to any vital duties such as
"pingponging" (server verifies that you are still there by sending
"PING" and expects a "PONG" in return.)

For this reason I was thinking: do you think I should run a new thread
whenever a new command is invoked by a user? And have the thread
delete itself when it's completed execution? This way the bot would
*always* be free to do its duties.

Any help is much appreciated.

M. Baker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Telegram bot api 0
(discord.py) 'async_generator' has no attribute 'flatten' 1
Python IRC bot using Twisted 4
IRC Bot trouble.. 0
Python IRC Zork 2
[QUIZ] IRC Teams (#221) 1
IRC bot test 1
IRC Trivia Bot 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top