python-irclib and threading

R

Robin Krahl

Hi folks,

I’m writing a program with a component that has to connect to IRC and
call a callback function in case of a message. I tried using
python-irclib for doing this, and executing the code in the main thread
worked fine. When I moved the code part into the run method of a
threading.Thread class, it doesn’t work anymore. The code is:

# …
def run(self):
# …
self._lg.debug('AAA')
irc = irclib.IRC()
server = irc.server()
server.connect('irc.freenode.net', 6667, 'rcc')
self._lg.debug('BBB')
irc.process_forever()
self._lg.debug('CCC')
# …
# …

(self._lg = logging.getLogger(…))

Now, the connect method does not return. That means that ‘AAA’ is
logged while ‘BBB’ and ‘CCC’ are not displayed (yes, I waited long
enough).

My guess was that the problem is that I have to call the connect()
method from the main thread. Is this right? If yes, what can I do
about it? If no, do you have an idea what’s the problem?

Best regards,
Robin

--
Robin Krahl || ireas
http://robin-krahl.de
(e-mail address removed)


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iFYEARELAAYFAky0daUACgkQMmq4cQVLkmDYpADfV6ldJUjhq1SAVJabSSVjKYtD
n+af8GGMpweZbADfQzJ6lwLuIT4hHCb0HZuBweISMmi1D1MruCWppg==
=zRbJ
-----END PGP SIGNATURE-----
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top