summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorKrzysztof A. Adamski <krzysztofa@gmail.com>2008-06-07 15:03:27 -0400
committerKrzysztof A. Adamski <krzysztofa@gmail.com>2008-06-07 15:03:27 -0400
commitbb80b6e6f10bd97b2926f447e913d8249592c32d (patch)
tree95029b217bd72a6562260a27b752fc86d462d5b2 /func
parent9acec083713038365e804464cfaf7c22a405d0a0 (diff)
downloadthird_party-func-bb80b6e6f10bd97b2926f447e913d8249592c32d.tar.gz
third_party-func-bb80b6e6f10bd97b2926f447e913d8249592c32d.tar.xz
third_party-func-bb80b6e6f10bd97b2926f447e913d8249592c32d.zip
Change bsddb which is leaking on new python versions.
Diffstat (limited to 'func')
-rw-r--r--func/forkbomb.py17
-rw-r--r--func/jobthing.py8
2 files changed, 16 insertions, 9 deletions
diff --git a/func/forkbomb.py b/func/forkbomb.py
index 7cc9df3..ef0817a 100644
--- a/func/forkbomb.py
+++ b/func/forkbomb.py
@@ -16,7 +16,7 @@ import os
import random # for testing only
import time # for testing only
import shelve
-import bsddb
+import dbm
import sys
import tempfile
import fcntl
@@ -39,10 +39,10 @@ def __access_buckets(filename,clear,new_key=None,new_value=None):
modifying it as required.
"""
- internal_db = bsddb.btopen(filename, 'c', 0644 )
- handle = open(filename,"r")
+ handle = open(filename,"w")
fcntl.flock(handle.fileno(), fcntl.LOCK_EX)
- storage = shelve.BsdDbShelf(internal_db)
+ internal_db = dbm.open(filename, 'c', 0644 )
+ storage = shelve.Shelf(internal_db)
if clear:
storage.clear()
@@ -138,7 +138,14 @@ def batch_run(pool,callback,nforks=DEFAULT_FORKS,cachedir=DEFAULT_CACHE_DIR):
buckets = __bucketize(pool, nforks)
__forkbomb(0,buckets,callback,shelf_file)
rc = __access_buckets(shelf_file,False,None)
- os.remove(shelf_file)
+
+ try: #it's only cleanup so don't care if the files disapeared
+ os.remove(shelf_file)
+ os.remove(shelf_file+".pag")
+ os.remove(shelf_file+".dir")
+ except OSError:
+ pass
+
return rc
def __test(nforks=4,sample_size=20):
diff --git a/func/jobthing.py b/func/jobthing.py
index c7eb179..aa801bc 100644
--- a/func/jobthing.py
+++ b/func/jobthing.py
@@ -18,7 +18,7 @@ import os
import random # for testing only
import time # for testing only
import shelve
-import bsddb
+import dbm
import sys
import fcntl
import forkbomb
@@ -66,10 +66,10 @@ def __access_status(jobid=0, status=0, results=0, clear=False, write=False, purg
os.makedirs(dir)
filename = os.path.join(dir,"status-%s" % os.getuid())
- internal_db = bsddb.btopen(filename, 'c', 0644 )
- handle = open(filename,"r")
+ handle = open(filename,"w")
fcntl.flock(handle.fileno(), fcntl.LOCK_EX)
- storage = shelve.BsdDbShelf(internal_db)
+ internal_db = dbm.open(filename, 'c', 0644 )
+ storage = shelve.Shelf(internal_db)
if clear: