When two or more clients try to connect to the same IRC network simultaneously, for the first client hitting the server, we create a bot instance to connect to the IRC server, and for the subsequent clients, we try to reuse the existing bot and start sending messages to the IRC server. But there's a time, when the IRC bot is instantiated, but not yet connected to the IRC, and the other clients try to send message to the IRC server, and it fails.
[2015-12-01 17:50:02][ bouncer ERROR] get_bot_handle error: 'IrcbBot' object has no attribute 'protocol'
Traceback (most recent call last):
File "ircb/bouncer.py", line 156, in get_bot_handle
bot.raw('NAMES %s' % channel.name)
File "/home/rtnpro/waartaa/ircb/ircb/irc/__init__.py", line 160, in raw
self.send_line(message)
File "/home/rtnpro/.virtualenvs/ircb/lib/python3.4/site-packages/irc3/__init__.py", line 162, in send_line
self.send(data.replace('\n', ' ').replace('\r', ' '))
File "/home/rtnpro/.virtualenvs/ircb/lib/python3.4/site-packages/irc3/__init__.py", line 166, in send
self._send(data)
File "/home/rtnpro/.virtualenvs/ircb/lib/python3.4/site-packages/irc3/__init__.py", line 169, in _send
self.protocol.write(data)
AttributeError: 'IrcbBot' object has no attribute 'protocol'
Solution
We need to use some kind of mutex to block other client requests until the IRC bot is connected to the IRC server.
Problem
When two or more clients try to connect to the same IRC network simultaneously, for the first client hitting the server, we create a bot instance to connect to the IRC server, and for the subsequent clients, we try to reuse the existing bot and start sending messages to the IRC server. But there's a time, when the IRC bot is instantiated, but not yet connected to the IRC, and the other clients try to send message to the IRC server, and it fails.
Solution
We need to use some kind of
mutex
to block other client requests until the IRC bot is connected to the IRC server.