File: masscreate2.py

package info (click to toggle)
sqlalchemy 0.6.3-3%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 10,744 kB
  • ctags: 15,132
  • sloc: python: 93,431; ansic: 787; makefile: 137; xml: 17
file content (36 lines) | stat: -rw-r--r-- 975 bytes parent folder | download
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
import testenv; testenv.simple_setup()

import random, string

from sqlalchemy.orm import attributes
from sqlalchemy.test.util import gc_collect

# with this test, run top.  make sure the Python process doenst grow in size arbitrarily.

class User(object):
    pass

class Address(object):
    pass

attributes.register_attribute(User, 'id', False, False)
attributes.register_attribute(User, 'name', False, False)
attributes.register_attribute(User, 'addresses', True, False)
attributes.register_attribute(Address, 'email', False, False)
attributes.register_attribute(Address, 'user', False, False)


for i in xrange(1000):
  for j in xrange(1000):
    u = User()
    attributes.manage(u)
    u.name = str(random.randint(0, 100000000))
    for k in xrange(10):
      a = Address()
      a.email_address = str(random.randint(0, 100000000))
      attributes.manage(a)
      u.addresses.append(a)
      a.user = u
  print "clearing"
  #managed_attributes.clear()
  gc_collect()