Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36bcecd

Browse files
committed
Rename bufchan to channel
After all, we are dealing with an abstract channel, no need to know if its buffered or not in the patterns.
1 parent c497605 commit 36bcecd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

zerorpc/patterns.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,66 +25,66 @@
2525

2626
class ReqRep:
2727

28-
def process_call(self, context, bufchan, req_event, functor):
28+
def process_call(self, context, channel, req_event, functor):
2929
context.hook_server_before_exec(req_event)
3030
result = functor(*req_event.args)
31-
rep_event = bufchan.create_event('OK', (result,),
31+
rep_event = channel.create_event('OK', (result,),
3232
context.hook_get_task_context())
3333
context.hook_server_after_exec(req_event, rep_event)
34-
bufchan.emit_event(rep_event)
34+
channel.emit_event(rep_event)
3535

3636
def accept_answer(self, event):
3737
return True
3838

39-
def process_answer(self, context, bufchan, req_event, rep_event,
39+
def process_answer(self, context, channel, req_event, rep_event,
4040
handle_remote_error):
4141
if rep_event.name == 'ERR':
4242
exception = handle_remote_error(rep_event)
4343
context.hook_client_after_request(req_event, rep_event, exception)
4444
raise exception
4545
context.hook_client_after_request(req_event, rep_event)
46-
bufchan.close()
46+
channel.close()
4747
result = rep_event.args[0]
4848
return result
4949

5050

5151
class ReqStream:
5252

53-
def process_call(self, context, bufchan, req_event, functor):
53+
def process_call(self, context, channel, req_event, functor):
5454
context.hook_server_before_exec(req_event)
5555
xheader = context.hook_get_task_context()
5656
for result in iter(functor(*req_event.args)):
57-
bufchan.emit('STREAM', result, xheader)
58-
done_event = bufchan.create_event('STREAM_DONE', None, xheader)
57+
channel.emit('STREAM', result, xheader)
58+
done_event = channel.create_event('STREAM_DONE', None, xheader)
5959
# NOTE: "We" made the choice to call the hook once the stream is done,
6060
# the other choice was to call it at each iteration. I don't think that
6161
# one choice is better than the other, so I'm fine with changing this
6262
# or adding the server_after_iteration and client_after_iteration hooks.
6363
context.hook_server_after_exec(req_event, done_event)
64-
bufchan.emit_event(done_event)
64+
channel.emit_event(done_event)
6565

6666
def accept_answer(self, event):
6767
return event.name in ('STREAM', 'STREAM_DONE')
6868

69-
def process_answer(self, context, bufchan, req_event, rep_event,
69+
def process_answer(self, context, channel, req_event, rep_event,
7070
handle_remote_error):
7171

7272
def is_stream_done(rep_event):
7373
return rep_event.name == 'STREAM_DONE'
74-
bufchan.on_close_if = is_stream_done
74+
channel.on_close_if = is_stream_done
7575

7676
def iterator(req_event, rep_event):
7777
while rep_event.name == 'STREAM':
7878
# Like in process_call, we made the choice to call the
7979
# after_exec hook only when the stream is done.
8080
yield rep_event.args
81-
rep_event = bufchan.recv()
81+
rep_event = channel.recv()
8282
if rep_event.name == 'ERR':
8383
exception = handle_remote_error(rep_event)
8484
context.hook_client_after_request(req_event, rep_event, exception)
8585
raise exception
8686
context.hook_client_after_request(req_event, rep_event)
87-
bufchan.close()
87+
channel.close()
8888

8989
return iterator(req_event, rep_event)
9090

0 commit comments

Comments
 (0)