diff options
author | Federico Di Gregorio <fog@initd.org> | 2006-01-10 16:13:37 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2006-01-10 16:13:37 +0000 |
commit | 5871596eda7875e3a0cadb4db6fceb4c2995f3c5 (patch) | |
tree | 737b69d669e5b493eaa7b80d2e3eee08b1fd9f23 /sandbox/stress2.py | |
parent | 1aed51693866f7e16afdfab1f9c1baefae30a9ef (diff) | |
download | psycopg2-5871596eda7875e3a0cadb4db6fceb4c2995f3c5.tar.gz |
Some more tests in sandbox.
Diffstat (limited to 'sandbox/stress2.py')
-rw-r--r-- | sandbox/stress2.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sandbox/stress2.py b/sandbox/stress2.py new file mode 100644 index 0000000..0e36dfc --- /dev/null +++ b/sandbox/stress2.py @@ -0,0 +1,42 @@ +import psycopg2 + +import threading, os, time, gc + +super_lock = threading.Lock() + +def f(): + try: + conn = psycopg2.connect('dbname=testx') + #c = db.cursor() + #c.close() + #conn.close() + del conn + except: + pass + #print "ERROR" + +def g(): + n = 30 + k = 0 + i = 1 + while i > 0: + while n > 0: + threading.Thread(target=f).start() + time.sleep(0.001) + threading.Thread(target=f).start() + time.sleep(0.001) + threading.Thread(target=f).start() + n -= 1 + while threading.activeCount() > 1: + time.sleep(0.01) + datafile = os.popen('ps -p %s -o rss' % os.getpid()) + line = datafile.readlines(2)[1].strip() + datafile.close() + n = 30 + print str(k*n) + '\t' + line + k += 1 + + while threading.activeCount()>1: + pass + +g()
\ No newline at end of file |