Non-Blocking I/O

Some Input-Output blocks the program until its finished. this is a problem in the IRC-Bot, because everything needs to wait until the operation is finished. Despite from blocking the bot from interacting with the user, even the network connection can get a timeout, because the bot cannot answer PING requests from the server.

Blocking I/O to avoid

  • urllib2.urlopen(“someurl”).read() is a popular method of retrieving a document via HTTP. It is blocking, so use lib.urlutils.download, which is non-blocking.
  • big file operations may need to get an own thread.