from cone_plant import *
if __name__ == '__main__':
if 'pop' in dir():
try:
pop.stop_exec_all_thread()
except:
pass
pop= ConePlantPopulation()
print pop.connect((raw_input('IP(localhost): ') or 'localhost', int(raw_input('Port('+str(PORT)+'): ') or str(PORT))))
pop.center= pop.get_sunpos()
print pop.set_colonyname()
p1= pop.new_interface(freq= (0.001, 0.0004, 0.00016, 0.000032,), standart_difference= 0.1, mutmut= 0)
# p1.exec_one_time()
# p1.start_exec_thread()
p1.interpret_one_time()
print p1.get_unknown_variables()
print pop.thread_id
print p1.Gcode
time.sleep(1);
print 'id:', p1.id, 'org_mat:', p1.get_org_mat()
print pop.group_join('coneplant', 'lalalilulilue')
print pop.formats_append([[[],[],[],[],[],[], True, True]])
# profiler
import profile
l= []
for i in range(input('How many threads shall be started? ')):
l.append(thread.start_new(profile.runctx, ('pop.exec_all_loop()', globals(), locals())))
f= file('profile.txt', 'w')
import sys
def stop_thread():
if not l:
return
_id= l.pop(0)
pop.stop_exec_all_thread(_id)
i= 0
if not 'idlelib' in dir():
while True:# not (raw_input() and raw_input('really kill pop?')):
f, sys.stdout= sys.stdout, f
print '#' * 80
print '##### i =', i
try:
stop_thread()
l.append(thread.start_new(profile.runctx, ('pop.exec_all_loop()', globals(), locals())))
except:
print pop.thread_id
time.sleep(100)
i+= 1
f, sys.stdout= sys.stdout, f
f.close()