python multiprocessing scheduling task -


i have 8 cpu core , 200 tasks done. each tasks isolate. there no need wait or share result. i'm looking way run 8 tasks/processes @ time (maximum) , when 1 of them finished. remaining task automatic start process.

how know when child process done , start new child process. first i'm trying use process(multiprocessing) , it's hard figure out. try use pool , face pickle problem cause need use dynamic instantiate.

edited : adding code of pool

class collectorparallel():  def fire(self,obj):     collectorcontroller = collectorcontroller()     collectorcontroller.crawltask(obj)  def start(self):     log_to_stderr(logging.debug)     pluginobjectlist = []     pluginname in self.settingmodel.getallcollectorname():         name = pluginname.capitalize()         #get plugin class , instanitiate object         module = __import__('plugins.'+pluginname,fromlist=[name])         pluginclass = getattr(module,name)         pluginobject = pluginclass()         pluginobjectlist.append(pluginobject)        pool = pool(8)     jobs = pool.map(self.fire,pluginobjectlist)     pool.close()      print pluginobjectlist 

pluginobjectlist got

[<plugins.name1.name1 instance @ 0x1f54290>, <plugins.name2.name2 instance @ 0x1f54f38>] 

picklingerror: can't pickle : attribute lookup builtin.instancemethod failed

but process version work fine

warning kinda subjective deployment , situation current setup follows

i have worker program, fire 6 copies (i have 6 cores). each worker following;

  1. connect redis instance
  2. try , pop work of specific list
  3. pushes logging information
  4. either idles or terminates on lack of work in 'queue'

then each program standalone while still doing work require separate queuing system. have no go-between on processes, might solution problem.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -