from dja setup_django import go go __file__ import processing from dja

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from dja.setup_django import go
go(__file__)
import processing
from django.db import connection
from google.models import Query
class Test:
def foo(self):
return Query.objects.all().count()
def do():
from django.db import connection
#connection.connection.close()
connection.connection = None
connection.cursor()
print '1', Test().foo()
print '2', Test().foo()
p = processing.Process(target=do)
p.start()
p.join()
print '3', Test().foo()
"""
Получаем хуйню вида:
lorien@lorien /web/seozilla/web_site $ python dbtest.py
2 4160
1 4160
3
Traceback (most recent call last):
File "dbtest.py", line 28, in ?
print '3', Test().foo()
File "dbtest.py", line 12, in foo
return Query.objects.all().count()
File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 244, in count
count = cursor.fetchone()[0]
psycopg2.ProgrammingError: no results to fetch
"""