in the following code, node 3 and node 4 running parallel

if there are 100 nodes running parallel, how can they notify each other

i find this post stackoverflow, 

http://stackoverflow.com/questions/29324346/how-do-i-connect-asyncio-coroutines-that-continually-produce-and-consume-data


if zeromq for python can not do notify among parallel nodes which means give 
handle to another def

my goal is to make each node can notify all other nodes if each node need

import asyncio
import time
from concurrent.futures import ProcessPoolExecutor

def f000():
 try:
  print "000"
  ex = ProcessPoolExecutor(2)
  yield from loop.run_in_executor(ex, time.sleep, 10)
 except:
  print "000 exception"

def f001():
 try:
  print "001"
  ex = ProcessPoolExecutor(2)
  yield from loop.run_in_executor(ex, time.sleep, 10)
 except:
  print "001 exception"

def f002():
 try:
  print "002"
  ex = ProcessPoolExecutor(2)
  yield from loop.run_in_executor(ex, time.sleep, 10)
 except:
  print "002 exception"

def f003():
 try:
  print "003"
  ex = ProcessPoolExecutor(2)
  yield from loop.run_in_executor(ex, time.sleep, 10)
 except:
  print "003 exception"

def f004():
 try:
  print "004"
  ex = ProcessPoolExecutor(2)
  yield from loop.run_in_executor(ex, time.sleep, 10)
 except:
  print "004 exception"

machine = {}
mappedfunc = {}
functionlist000 = []
functionlist001 = []
functionlist002 = []
functionlist003 = []
functionlist004 = []

functionlist000.append('002')
functionlist001.append('000')
functionlist002.append('003')
functionlist002.append('004')

functionlist003.append('001')
functionlist004.append('001')

machine000 = {'000': functionlist000}
machine001 = {'001': functionlist001}
machine002 = {'002': functionlist002}
machine003 = {'003': functionlist003}
machine004 = {'004': functionlist004}

machine.update(machine000)
machine.update(machine001)
machine.update(machine002)
machine.update(machine003)
machine.update(machine004)

functionkey000 = {'000': f000 }
functionkey001 = {'001': f001 }
functionkey002 = {'002': f002 }
functionkey002 = {'003': f003 }
functionkey002 = {'004': f004 }

mappedfunc.update(functionkey000)
mappedfunc.update(functionkey001)
mappedfunc.update(functionkey002)
mappedfunc.update(functionkey003)
mappedfunc.update(functionkey004)

def workingthreadpool(currentnumber1):
  i = 1
 #while i < 7:
  #i = i + 1
  functionlist0 = list(machine.get(currentnumber1).values())

  loop = asyncio.get_event_loop()
  tesks = []
  
  j = 1
  for functionlistelement in functionlist0
   tesks.append(asyncio.ensure_future(mappedfunc.get(functionlistelement)()))
   if j > 1:
    workingthreadpool(functionlistelement)
   j = j + 1

  loop.run_until_complete(asyncio.wait_for(tesks, 1))
  loop.close()

currentnumber = "000"
workingthreadpool(currentnumber)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to