Use threading.local to separate sessions.

The fedbadges backend was designed to only have one thread.

This past week we gave it many threads (so that it could keep up with
its increasingly demanding workload), but this has started to generate
crashes from race conditions (mostly inside sqlalchemy).

This patch will not solve all of those problems, but it will solve some.
This will make it so that *each* thread will get its very own database
session so that they don't stomp on each other quite so much.