11import msgpack
22
3- from msgpackrpc import inPy3k
43from msgpackrpc import Loop
54from msgpackrpc import message
65from msgpackrpc .error import RPCError
@@ -51,7 +50,6 @@ def send_request(self, method, args):
5150 future = Future (self ._loop , self ._timeout )
5251 self ._request_table [msgid ] = future
5352 self ._transport .send_message ([message .REQUEST , msgid , method , args ])
54-
5553 return future
5654
5755 def notify (self , method , * args ):
@@ -67,11 +65,10 @@ def close(self):
6765 self ._request_table = {}
6866
6967 def on_connect_failed (self , reason ):
70- """\
68+ """
7169 The callback called when the connection failed.
7270 Called by the transport layer.
7371 """
74-
7572 # set error for all requests
7673 #for msgid, future in self._request_table.iteritems():
7774 for msgid , future in _iteritems (self ._request_table ):
@@ -105,7 +102,7 @@ def on_timeout(self, msgid):
105102
106103 def step_timeout (self ):
107104 timeouts = []
108- for msgid , future in _iteritems ( self ._request_table ):
105+ for msgid , future in self ._request_table . iteritems ( ):
109106 if future .step_timeout ():
110107 timeouts .append (msgid )
111108
@@ -118,20 +115,14 @@ def step_timeout(self):
118115 future .set_error ("Request timed out" )
119116 self ._loop .start ()
120117
121- def _iteritems (dic ): # ugly!!!!!!
122- if inPy3k :
123- return dic .items ()
124- else :
125- return dic .iteritems ()
126118
127119def _NoSyncIDGenerator ():
128- """\
120+ """
129121 Message ID Generator.
130122
131123 NOTE: Don't use in multithread. If you want use this
132124 in multithreaded application, use lock.
133125 """
134-
135126 counter = 0
136127 while True :
137128 yield counter
0 commit comments