[PostgreSQL - Connection pooling] No results to fetch at restart of application
So if you are exiting/terminating your Python process, there's no need to call `close_idle()` because the process will exit anyways, closing everything.

I'm not sure what's going on as far as when the subprocesses are getting forked (before or after the connection pool is initialized? hopefully before). Or what the shutdown/restart behavior is... Or what kinds of queries would trigger the errors you're observing... So many questions. Could this just a timing issue where your db isn't ready when you're attempting to connect/query?

If you can reproduce this reliably without requiring docker or uwsgi or bottle web framework (e.g., just peewee and postgres) I'll reopen.
Hello,

I am using Peewee in combination with Bottle web framework, uWSGI and Docker.
I have 10 uWSGI workers running in a Docker container. Each worker connects to a PostgreSQL database using connection pooling :
```
from playhouse.pool import *
database = PooledPostgresqlDatabase(None)
database.init(db_name, max_connections=2, stale_timeout=300, **db_args)
```

Each worker opens DB connection before request and closes it afterwards :
```
@webapp.hook('before_request')
def before_request():
    database.connect()

@webapp.hook('after_request')
def after_request():
    if not database.is_closed():
        database.close()
```

I am also using an exit handler to close all idle connections when gracefully stopping uWSGI worker :
```
import atexit
atexit.register(exit_handler, database)

def exit_handler(database):
    database.close_idle()
    sys.exit(0)
```

The issue I have is when restarting Docker container. During approx 5/10 minutes, I get a lot of following PostgreSQL errors (`psycopg2.ProgrammingError: no results to fetch`) on many peewee requests (not all).

And on database side, I get many warnings like these :
```
WARNING:  there is no transaction in progress
WARNING:  there is already a transaction in progress
```

However, when looking at active connections to DB from app using netstat, all connections are correctly dropped when stopping container.

Any ideas about this one ?

Thanks for your help !