[PATCH] Correctly handle forks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make sure that forks is parsed as an integer and also correctly passed to the forkbomb module

http://github.com/ixs/func/commit/9ce5e67b3021ad54663e2176967507a32c488efb

 client.py           |    4 ++--
 cmd_modules/call.py |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Right now when defining --forks=5 there are two problems:

1. The number is parsed as a string breaking forkbomb.py further down the line with the following problem:
unsupported operand type(s) for %: 'int' and 'str'
...
File "/usr/lib/python2.4/site-packages/func/forkbomb.py", line 78, in __bucketize
    slot = count % slots

2. Pass self.nforks instead of nforks. The former actually contains the wanted number of forks...

cheers,
 andreas


diff --git a/func/overlord/client.py b/func/overlord/client.py
index 10dd582..6596483 100644
--- a/func/overlord/client.py
+++ b/func/overlord/client.py
@@ -686,10 +686,10 @@ class Overlord(object):
             if self.nforks > 1 or self.async:
                 # using forkbomb module to distribute job over multiple threads
                 if not self.async:
-                    results = forkbomb.batch_run(minionurls, process_server, nforks)
+                    results = forkbomb.batch_run(minionurls, process_server, self.nforks)
                 else:
                     minion_info =dict(spec=spec,module=module,method=method)
-                    results = jobthing.batch_run(minionurls, process_server,nforks,**minion_info)
+                    results = jobthing.batch_run(minionurls, process_server, self.nforks, **minion_info)
             else:
                 # no need to go through the fork code, we can do this directly
                 results = {}
diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py
index bad5260..b82b88e 100644
--- a/func/overlord/cmd_modules/call.py
+++ b/func/overlord/cmd_modules/call.py
@@ -177,7 +177,7 @@ class Call(base_command.BaseCommand):
         self.parser.add_option("-b", "--basic", dest="basic",
                                help="output return data with minimal, basic formating",
                                action="store_true")
-        self.parser.add_option("-f", "--forks", dest="forks",
+        self.parser.add_option("-f", "--forks", dest="forks", type="int",
                                help="how many parallel processes?  (default 1)",
                                default=self.forks)
         self.parser.add_option("-a", "--async", dest="async",
_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux