python-irclib and threading

Discussion in 'Python' started by Robin Krahl, Oct 12, 2010.

  1. Robin Krahl

    Robin Krahl Guest

    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



    -----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-----
    Robin Krahl, Oct 12, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tina I

    irclib problems

    Tina I, Feb 11, 2007, in forum: Python
    Replies:
    1
    Views:
    460
    David Boddie
    Feb 12, 2007
  2. Dropkick Punt

    Connection problems with irclib

    Dropkick Punt, Apr 11, 2007, in forum: Python
    Replies:
    3
    Views:
    242
    Cousin Stanley
    Apr 12, 2007
  3. Replies:
    9
    Views:
    1,001
    Mark Space
    Dec 29, 2007
  4. Steven Woody
    Replies:
    0
    Views:
    393
    Steven Woody
    Jan 9, 2009
  5. Steven Woody
    Replies:
    0
    Views:
    428
    Steven Woody
    Jan 9, 2009
Loading...

Share This Page