Tag Archives: threads

Make sure you are closing the DB connections after accessing Django ORM in your threads

I was writing a service which import various feeds and then post to another RESTful API, simple enough as below: from django.db import connections class Receiver(PolymorphicModel): … class Database(Receiver): name = models.CharField(max_length=255) def get_data_source(self): return connections[name] Then the feed model: class Feed(models.Model): receiver = models.ForeignKey(‘Receiver’) def get_data_source(self): return self.receiver.get_real_instance().get_data_source() Then run this feed in trivial… Read More »