python - twisted client transport.write not sending data, even after close -


i writing server in twisted needs propagate information other servers. implement this, have written simple client protocol writes given server. use deferreds call transport.write(), , have confirmed through print statements callback called, never output server.

my code here: https://gist.github.com/sakekasi/9460002

maybe i'm preventing reactor running reason? i'm pretty sure haven't, don't use long running loops.

thanks in advance.

edit: quick walkthrough of code

i'm instantiating 5 servers according dictionary ports. each server, create new factory , bind respective port.

invalid commands: given invalid command, server must reply ? command

iamat: 'iamat name lat lon time' must responded @ servername name lat lon time. in addition, server recieves command proceeds propagate servers under name in talks dictionary. so, instantiate clients client factory, , have them send message right port based on ports dictionary.

for code details, @ respond.iamat

the final line in parse_message(line) reads:

{... }.get(toks[0], inv)() 

i think should

{... }.get(toks[0])() 

edit

i can send iamat message , have parsed server:

nc -c localhost 12604 iamat b 1 2 3 @ young 1394489423.5 b 1.0 2.0 3.0 

but i'm little confused should happen next. server seems attempt establish new connections using tcp4clientendpoint (rather using existing connections clients) in order send at messages. there seems problem here messages aren't sent, if succeeded, wouldn't result in continuous loop of messages going , forth within server?

edit 2

thanks clarification. default, twisted's linereceiver expects lines terminated carriage return , new line character (\r\n). messages being sent, subsequently ignored flatten_cmd function appends \n. changing following fixes problem:

def flatten_cmd(schema, cmd):     ret = cmd['type']     x in schema:         k = x[0]         ret = ret + ' ' + str(cmd[k])     return ret+'\r\n' 

and server receives updates expected:

got iamat blah 1 2 3 sending @ farmar 1394676270.11 blah 1.0 2.0 3.0 sending @ farmar 1394676270.11 blah 1.0 2.0 3.0 got @ farmar 1394676270.11 blah 1.0 2.0 3.0 got @ farmar 1394676270.11 blah 1.0 2.0 3.0 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -