Login

Tag "twisted"

Snippet List

Multi-DB Reconnecting Persistent Postgres Connection

This is a modification of http://djangosnippets.org/snippets/1707/ that handles the database going down or PG Bouncer killing the connection. This also works in things like Twisted to make sure the connection is alive before doing a real query. Thanks @mike_tk for the original post! EDIT: Updated the wrapper to handle multi-db. Before it was using the first connection it made, now it creates an attribute name for the connection based on the name of the database.

  • database
  • multi-db
  • twisted
  • connection
  • persistent
  • multiple-databases
  • socket
  • web-socket
Read More

Twisted protocol for receiving logging module messages over a socket

When using Python's logging module in a concurrent environment (e.g. mod_python), messages get dropped by the standard file-based handlers. The [SocketHandler](http://www.python.org/doc/2.5.2/lib/node414.html) allows you to send logging messages to a remote socket. This snippet provides code for listening for such messages and writing them out to a log file. The final log file is configured as a standard logging file-based handler.

  • logging
  • twisted
Read More

3 snippets posted so far.