irccat.py pings out

Anonymous avatarAnonymous created an issue

If you play around with irccat long enough, it will eventually ping timeout.

Comments (1)

  1. Jason R. Coombs

    irccat (and other scripts in the examples directories) aren't designed to be production-class scripts. Instead, they're designed to help the developer gain a familiarity with the system.

    As a result, the example is very simple and doesn't account for higher-level behaviors (like ping timeouts, or processing incoming messages at all for that matter).

    The way the irc library handles asynchronous I/O is through callbacks, so it's important that the process_once be called periodically to handle incoming messages (pings) and respond accordingly.

    You might try calling process_once in the loop, which may cause the "ping-ponger" to respond to pings:

    C:\Users\jaraco\projects\irc [default ~1 master tip]> hg diff
    diff -r af0a10dde638 scripts/irccat.py
    --- a/scripts/irccat.py Sun Sep 22 18:09:50 2013 -0400
    +++ b/scripts/irccat.py Sun Oct 20 15:52:03 2013 -0400
    @@ -34,6 +34,7 @@
         for line in itertools.takewhile(bool, get_lines()):
             print(line)
             connection.privmsg(target, line)
    +        connection.irclibobj.process_once()
         connection.quit("Using irc.client.py")
    
     def on_disconnect(connection, event):
    

    However, even that isn't necessarily going to work if input from stdin isn't received frequently enough to trigger the ping responses.

    Your other option would be to create a separate thread or other asynchronous technique to ensure that 'process_once' is called periodically even when input isn't received on stdin.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.