def process_incoming(self):
model = self.model<EOL>sockets = self.sockets<EOL>if not sockets:<EOL><INDENT>return<EOL><DEDENT>poller = sockets['<STR_LIT>']<EOL>rep = sockets['<STR_LIT>']<EOL>pub = sockets['<STR_LIT>']<EOL>items = poller.poll(<NUM_LIT:10>)<EOL>for sock, n in items:<EOL><INDENT>for i in range(n):<EOL><INDENT>A, metadata = recv_array(sock)<EOL>var = None<EOL>if "<STR_LIT>" in metadata:<EOL><INDENT>dt = float(metadata["<STR_LIT>"])<EOL>model.update(dt)<EOL>metadata["<STR_LIT>"] = dt<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>name = metadata["<STR_LIT>"]<EOL>if metadata.get("<STR_LIT>", False):<EOL><INDENT>var = model.get_var(name).copy()<EOL><DEDENT>else:<EOL><INDENT>var = model.get_var(name)<EOL><DEDENT>if var is None:<EOL><INDENT>logger.warning("<STR_LIT>" % name)<EOL><DEDENT>metadata['<STR_LIT:name>'] = name<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>n = model.get_var_count()<EOL>metadata['<STR_LIT>'] = n<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>var_name = metadata['<STR_LIT>']<EOL>n = model.get_var_rank(var_name)<EOL>metadata['<STR_LIT>'] = n<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>var_name = metadata['<STR_LIT>']<EOL>n = model.get_var_shape(var_name)<EOL>metadata['<STR_LIT>'] = tuple([int(item) for item in n])<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>var_name = metadata['<STR_LIT>']<EOL>n = model.get_var_type(var_name)<EOL>metadata['<STR_LIT>'] = n<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>i = int(metadata["<STR_LIT>"])<EOL>name = model.get_var_name(i)<EOL>metadata['<STR_LIT>'] = name<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>t = float(metadata["<STR_LIT>"])<EOL>model.set_current_time(t)<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>name = metadata["<STR_LIT>"]<EOL>model.set_var(name, A)<EOL>metadata["<STR_LIT:name>"] = name  <EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>name = metadata["<STR_LIT>"]<EOL>logger.debug("<STR_LIT>", name)<EOL>start = metadata["<STR_LIT:start>"]<EOL>count = metadata["<STR_LIT:count>"]<EOL>model.set_var_slice(name, start, count, A)<EOL>metadata["<STR_LIT:name>"] = name  <EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>name = metadata["<STR_LIT>"]<EOL>logger.debug("<STR_LIT>", name)<EOL>index = metadata["<STR_LIT:index>"]<EOL>var = model.get_var(name).copy()<EOL>var.flat[index] = A<EOL>model.set_var(name, var)<EOL>metadata["<STR_LIT:name>"] = name  <EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>metadata["<STR_LIT>"]<EOL>t = model.get_current_time()<EOL>metadata['<STR_LIT>'] = t<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>metadata["<STR_LIT>"]<EOL>dt = model.get_time_step()<EOL>metadata['<STR_LIT>'] = dt<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>metadata["<STR_LIT>"]<EOL>t = model.get_end_time()<EOL>metadata['<STR_LIT>'] = t<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>metadata["<STR_LIT>"]<EOL>t = model.get_start_time()<EOL>metadata['<STR_LIT>'] = t<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>assert metadata["<STR_LIT>"] in {<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"}<EOL>model.state = metadata["<STR_LIT>"]<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>pass<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>config_file = metadata["<STR_LIT>"]<EOL>model.initialize(str(config_file))<EOL><DEDENT>elif "<STR_LIT>" in metadata:<EOL><INDENT>model.finalize()<EOL><DEDENT>else:<EOL><INDENT>logger.warn("<STR_LIT>".format(str(metadata), sock))<EOL><DEDENT>if sock.socket_type == zmq.REP:<EOL><INDENT>send_array(rep, var, metadata=metadata)<EOL><DEDENT>elif any(x.startswith("<STR_LIT>") for x in metadata) and sock.socket_type == zmq.PULL:<EOL><INDENT>send_array(pub, var, metadata=metadata)<EOL><DEDENT><DEDENT><DEDENT>
process incoming messages

data is a dict with several arrays