Problem with flask debug mode and automatic restart
I found this in documentation: http://peewee.readthedocs.org/en/latest/peewee/cookbook.html#multi-threaded-applications but in Flask autoreload case, I'm not using threads. Can use these options to work around it though.
 Looks like the werkzeug debugger uses multiple threads:

https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/serving.py#L585

To suppress these errors you can configure your database `threadlocals=True` or use the sqlite driver's `check_same_thread=False`
 `check_same_thread=False` is useful.

Hi,

I have following code:

``` python
from flask import Flask

import peewee

app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'

db = peewee.SqliteDatabase('test.sqlite')


class BaseModel(peewee.Model):
    class Meta:
        database = db


class User(BaseModel):
    username = peewee.CharField(max_length=80)
    email = peewee.CharField(max_length=120)

    def __unicode__(self):
        return self.username


class Post(BaseModel):
    title = peewee.CharField(max_length=120)
    text = peewee.TextField(null=False)
    date = peewee.DateTimeField()

    user = peewee.ForeignKeyField(User)

    def __unicode__(self):
        return self.title


@app.route('/')
def index():
    for p in Post.select():
        print p
    return '<a href="/admin/">Click me to get to Admin!</a>'


if __name__ == '__main__':
    try:
        User.create_table()
        Post.create_table()
    except:
        pass

    app.debug = True
    app.run('0.0.0.0', 8000)
```

and whenever I try to open index view, I get following exception: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 7052 and this is thread id 884.

This issue happens only when debug set to True and at least one restart happened.
