Pool creation callback fix

Pool creation callback should be run after
connection is added to the pool. Otherwise its
being executed only after size-1 connections are ready.
Preventing CPU hogging while connection waiting

Instead of instantly retrying to get new
available connection, doing that with small timeout.
Otherwise tornado goes to 100% CPU usage while waiting
for next avaiable connection.
Support for volatile database server

Initializing pool with raise_connect_errors=False will make it
to track connections status and (try) to reconnect to server on
demand.
Fixed Pool callback

Now Pool callback is executed only after really all conecttions
are ready.
Returning early if decided to reanimate connection
Using ioloop's time

ioloop.time() is a proper way to get relative elapsed time.
Using subscription instead of busy-wait

When no connection are available - allocating Future
to get notified when there are free connections in pool.
Its better then doing busy-wait - prevents starvation
and uses less resources.
Dynamic pool sizing + bug fixes
code cleanup
Fixed bug in after-connect callback inocation

Introduced as part of migration to "pending"
connection.
After-connect callback should be invoked when
there are no pedning connections any more
PEP8 compliance
Added support for set_session

Now one can specifiy a set of commands to execute when
connection is established.
The commands are executed as a single transaction block.

TBD: Handle exceptions caused by set session commands.
     We probably want to distinguish between connection related errors
	 and errors caused by incorrect SQL.
Revert "Added support for set_session"

This reverts commit 8623d17291be301b036f89f68e21902a1efa4ced.

Bad implementation
Proper implementation for set_session

From now on set_session (*list* of sql commands) can be passed
to the Pool and Connection object.
For the sake of robustness, if set_session commands fail, the
connection is closed and considered dead.
connection management and stretch fix

* Connections can now be explicitely managed using `getconn`/`putconn`
  Additionally there is a `manage` context manage to automate `putcon`
* Added example to demonstrate the above feature
* Fixed bug in pool stretching - pool was stretched on restoring
  dead connections even there was only single incoming request

Signed-off-by: Zaar Hai <haizaar@haizaar.com>
Fixing mogrify test

I do not know much about mogrify, but current
psycopg2 (2.5.2) in stand-alone mode produce perfectly same results.
Renamed set_session to setsession

This makes implementation code more readable

Signed-off-by: Zaar Hai <haizaar@haizaar.com>
Added parallel execution unit test
Added setsession unit test
Added pool stretching unit test