summaryrefslogtreecommitdiffstats
path: root/func/forkbomb.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-01-29 16:19:30 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-01-29 16:19:30 -0500
commitb3c5591d70c1c354d14267e804ab64872af97b40 (patch)
treea361f4d0ea060df23ffbccf9961f38bb01a65d23 /func/forkbomb.py
parent1d60f197dab809e9a51c3377587d46370e698c52 (diff)
downloadthird_party-func-b3c5591d70c1c354d14267e804ab64872af97b40.tar.gz
third_party-func-b3c5591d70c1c354d14267e804ab64872af97b40.tar.xz
third_party-func-b3c5591d70c1c354d14267e804ab64872af97b40.zip
All exceptions, async or otherwise, now come back as easily detectable signatures. Use utils.is_error(result)
to determine if something is an error or isn't. Example scripts as well as func-inventory have been updated. See async_test.py for examples.
Diffstat (limited to 'func/forkbomb.py')
-rw-r--r--func/forkbomb.py8
1 files changed, 1 insertions, 7 deletions
diff --git a/func/forkbomb.py b/func/forkbomb.py
index 3dc12c8..3dfa6f2 100644
--- a/func/forkbomb.py
+++ b/func/forkbomb.py
@@ -21,6 +21,7 @@ import sys
import tempfile
import fcntl
import utils
+import xmlrpclib
DEFAULT_FORKS = 4
DEFAULT_CACHE_DIR = "/var/lib/func"
@@ -54,15 +55,12 @@ def __access_buckets(filename,clear,new_key=None,new_value=None):
if not storage.has_key("data"):
storage["data"] = {}
else:
- # print "DEBUG: existing: %s" % storage["data"]
pass
if new_key is not None:
# bsdb is a bit weird about this
newish = storage["data"].copy()
- new_value = utils.remove_exceptions(new_value)
newish[new_key] = new_value
- # print "DEBUG: newish: %s" % newish
storage["data"] = newish
rc = storage["data"].copy()
@@ -78,14 +76,12 @@ def __bucketize(pool, slots):
"""
buckets = {}
count = 0
- # print "DEBUG: slots: %s" % slots
for key in pool:
count = count + 1
slot = count % slots
if not buckets.has_key(slot):
buckets[slot] = []
buckets[slot].append(key)
- # print "DEBUG: buckets: %s" % buckets
return buckets
def __with_my_bucket(bucket_number,buckets,what_to_do,filename):
@@ -139,11 +135,9 @@ def batch_run(pool,callback,nforks=DEFAULT_FORKS,cachedir=DEFAULT_CACHE_DIR):
if nforks <= 1:
# modulus voodoo gets crazy otherwise and bad things happen
nforks = 2
- # print "DEBUG: nforks=%s" % 2
shelf_file = __get_storage(cachedir)
__access_buckets(shelf_file,True,None)
buckets = __bucketize(pool, nforks)
- # print "DEBUG: buckets: %s" % buckets
__forkbomb(1,buckets,callback,shelf_file)
rc = __access_buckets(shelf_file,False,None)
os.remove(shelf_file)