Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python-irclib and threading

Reply
Thread Tools

python-irclib and threading

 
 
Robin Krahl
Guest
Posts: n/a
 
      10-12-2010
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
http://www.velocityreviews.com/forums/(E-Mail Removed)


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

iFYEARELAAYFAky0daUACgkQMmq4cQVLkmDYpADfV6ldJUjhq1 SAVJabSSVjKYtD
n+af8GGMpweZbADfQzJ6lwLuIT4hHCb0HZuBweISMmi1D1MruC Wppg==
=zRbJ
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: threading in PyQt vs threading in standard library Steven Woody Python 0 01-09-2009 07:48 AM
threading in PyQt vs threading in standard library Steven Woody Python 0 01-09-2009 07:15 AM
Cooperative threading preemptive threading - a bit confused failure_to@yahoo.co.uk Java 9 12-29-2007 01:10 AM
threading and multicores, pros and cons Maric Michaud Python 24 02-20-2007 07:47 PM
Threading and Session Objects Roberto López ASP .Net 10 08-05-2003 07:23 AM



Advertisments