2

I'm using Django 1.2 and django-mssql.

While performing the following

for unicorn in Unicorn.objects.all():
    print unicorn.color

I'm getting the following error at around the 100th iteration:

com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft SQL Server Nativ e Client 10.0', u'The object is in a zombie state. An object may enter a zombie state when either ITransaction::Commit or ITransaction::Abort is called, or when a storage object was created and not yet released.', None, 0, -2147418113), Non e)


Any idea? This is really bugging me... starting to hate the whole Windows Server world... :(

RadiantHex
  • 24,907
  • 47
  • 148
  • 244
  • COM error is not a joke (I'm a former DirectX developer, I see COM errors in my nightmares), and COM error + zombie is a real Resident Evil :-) – Tomasz Zieliński Nov 16 '10 at 20:32

2 Answers2

1

I had a similar problem and I resolved it by forcing the full QuerySet to be retrieved before using it in the for loop. So, try this:

for unicorn in list(Unicorn.objects.all()):
    print unicorn.color
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Don
  • 16,928
  • 12
  • 63
  • 101
0

Another way is to set 'can_use_chunked_read = True' in base.DatabaseFeature:

sqlserver_ado/base.py: 16

class DatabaseFeatures(BaseDatabaseFeatures):
    uses_custom_query_class = True
    can_use_chunked_reads = False

I just set it and the error has gone away. Let me know if it solves your problem too.

Don
  • 16,928
  • 12
  • 63
  • 101