nwo
stringlengths 10
28
| sha
stringlengths 40
40
| path
stringlengths 11
97
| identifier
stringlengths 1
64
| parameters
stringlengths 2
2.24k
| return_statement
stringlengths 0
2.17k
| docstring
stringlengths 0
5.45k
| docstring_summary
stringlengths 0
3.83k
| func_begin
int64 1
13.4k
| func_end
int64 2
13.4k
| function
stringlengths 28
56.4k
| url
stringlengths 106
209
| project
int64 1
48
| executed_lines
list | executed_lines_pc
float64 0
153
| missing_lines
list | missing_lines_pc
float64 0
100
| covered
bool 2
classes | filecoverage
float64 2.53
100
| function_lines
int64 2
1.46k
| mccabe
int64 1
253
| coverage
float64 0
100
| docstring_lines
int64 0
112
| function_nodoc
stringlengths 9
56.4k
| id
int64 0
29.8k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/decorators.py
|
DecoratorBase._zerorpc_args
|
(self)
|
return args_spec
| 51 | 62 |
def _zerorpc_args(self):
try:
args_spec = self._functor._zerorpc_args()
except AttributeError:
try:
args_spec = inspect.getargspec(self._functor)
except TypeError:
try:
args_spec = inspect.getargspec(self._functor.__call__)
except (AttributeError, TypeError):
args_spec = None
return args_spec
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/decorators.py#L51-L62
| 36 |
[
0
] | 8.333333 |
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 91.666667 | false | 55.882353 | 12 | 4 | 8.333333 | 0 |
def _zerorpc_args(self):
try:
args_spec = self._functor._zerorpc_args()
except AttributeError:
try:
args_spec = inspect.getargspec(self._functor)
except TypeError:
try:
args_spec = inspect.getargspec(self._functor.__call__)
except (AttributeError, TypeError):
args_spec = None
return args_spec
| 22,505 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.__init__
|
(self)
| 38 | 53 |
def __init__(self):
super(zmq.Context, self).__init__()
self._middlewares = []
self._hooks = {
'resolve_endpoint': [],
'load_task_context': [],
'get_task_context': [],
'server_before_exec': [],
'server_after_exec': [],
'server_inspect_exception': [],
'client_handle_remote_error': [],
'client_before_request': [],
'client_after_request': [],
'client_patterns_list': [],
}
self._reset_msgid()
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L38-L53
| 36 |
[
0,
1,
2,
3,
15
] | 31.25 |
[] | 0 | false | 98.165138 | 16 | 1 | 100 | 0 |
def __init__(self):
super(zmq.Context, self).__init__()
self._middlewares = []
self._hooks = {
'resolve_endpoint': [],
'load_task_context': [],
'get_task_context': [],
'server_before_exec': [],
'server_after_exec': [],
'server_inspect_exception': [],
'client_handle_remote_error': [],
'client_before_request': [],
'client_after_request': [],
'client_patterns_list': [],
}
self._reset_msgid()
| 22,506 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._middlewares
|
(self)
|
return self.__dict__['_middlewares']
| 60 | 61 |
def _middlewares(self):
return self.__dict__['_middlewares']
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L60-L61
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _middlewares(self):
return self.__dict__['_middlewares']
| 22,507 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._middlewares
|
(self, value)
| 64 | 65 |
def _middlewares(self, value):
self.__dict__['_middlewares'] = value
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L64-L65
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _middlewares(self, value):
self.__dict__['_middlewares'] = value
| 22,508 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._hooks
|
(self)
|
return self.__dict__['_hooks']
| 68 | 69 |
def _hooks(self):
return self.__dict__['_hooks']
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L68-L69
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _hooks(self):
return self.__dict__['_hooks']
| 22,509 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._hooks
|
(self, value)
| 72 | 73 |
def _hooks(self, value):
self.__dict__['_hooks'] = value
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L72-L73
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _hooks(self, value):
self.__dict__['_hooks'] = value
| 22,510 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._msg_id_base
|
(self)
|
return self.__dict__['_msg_id_base']
| 76 | 77 |
def _msg_id_base(self):
return self.__dict__['_msg_id_base']
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L76-L77
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _msg_id_base(self):
return self.__dict__['_msg_id_base']
| 22,511 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._msg_id_base
|
(self, value)
| 80 | 81 |
def _msg_id_base(self, value):
self.__dict__['_msg_id_base'] = value
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L80-L81
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _msg_id_base(self, value):
self.__dict__['_msg_id_base'] = value
| 22,512 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._msg_id_counter
|
(self)
|
return self.__dict__['_msg_id_counter']
| 84 | 85 |
def _msg_id_counter(self):
return self.__dict__['_msg_id_counter']
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L84-L85
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _msg_id_counter(self):
return self.__dict__['_msg_id_counter']
| 22,513 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._msg_id_counter
|
(self, value)
| 88 | 89 |
def _msg_id_counter(self, value):
self.__dict__['_msg_id_counter'] = value
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L88-L89
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _msg_id_counter(self, value):
self.__dict__['_msg_id_counter'] = value
| 22,514 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._msg_id_counter_stop
|
(self)
|
return self.__dict__['_msg_id_counter_stop']
| 92 | 93 |
def _msg_id_counter_stop(self):
return self.__dict__['_msg_id_counter_stop']
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L92-L93
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _msg_id_counter_stop(self):
return self.__dict__['_msg_id_counter_stop']
| 22,515 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._msg_id_counter_stop
|
(self, value)
| 96 | 97 |
def _msg_id_counter_stop(self, value):
self.__dict__['_msg_id_counter_stop'] = value
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L96-L97
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 98.165138 | 2 | 1 | 100 | 0 |
def _msg_id_counter_stop(self, value):
self.__dict__['_msg_id_counter_stop'] = value
| 22,516 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.get_instance
|
()
|
return Context._instance
| 100 | 103 |
def get_instance():
if Context._instance is None:
Context._instance = Context()
return Context._instance
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L100-L103
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.165138 | 4 | 2 | 100 | 0 |
def get_instance():
if Context._instance is None:
Context._instance = Context()
return Context._instance
| 22,517 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context._reset_msgid
|
(self)
| 105 | 108 |
def _reset_msgid(self):
self._msg_id_base = tobytes(uuid.uuid4().hex)[8:]
self._msg_id_counter = random.randrange(0, 2 ** 32)
self._msg_id_counter_stop = random.randrange(self._msg_id_counter, 2 ** 32)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L105-L108
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.165138 | 4 | 1 | 100 | 0 |
def _reset_msgid(self):
self._msg_id_base = tobytes(uuid.uuid4().hex)[8:]
self._msg_id_counter = random.randrange(0, 2 ** 32)
self._msg_id_counter_stop = random.randrange(self._msg_id_counter, 2 ** 32)
| 22,518 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.new_msgid
|
(self)
|
return tobytes('{0:08x}'.format(self._msg_id_counter)) + self._msg_id_base
| 110 | 115 |
def new_msgid(self):
if self._msg_id_counter >= self._msg_id_counter_stop:
self._reset_msgid()
else:
self._msg_id_counter = (self._msg_id_counter + 1)
return tobytes('{0:08x}'.format(self._msg_id_counter)) + self._msg_id_base
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L110-L115
| 36 |
[
0,
1,
4,
5
] | 66.666667 |
[
2
] | 16.666667 | false | 98.165138 | 6 | 2 | 83.333333 | 0 |
def new_msgid(self):
if self._msg_id_counter >= self._msg_id_counter_stop:
self._reset_msgid()
else:
self._msg_id_counter = (self._msg_id_counter + 1)
return tobytes('{0:08x}'.format(self._msg_id_counter)) + self._msg_id_base
| 22,519 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.register_middleware
|
(self, middleware_instance)
|
return registered_count
| 117 | 130 |
def register_middleware(self, middleware_instance):
registered_count = 0
self._middlewares.append(middleware_instance)
for hook in self._hooks:
functor = getattr(middleware_instance, hook, None)
if functor is None:
try:
functor = middleware_instance.get(hook, None)
except AttributeError:
pass
if functor is not None:
self._hooks[hook].append(functor)
registered_count += 1
return registered_count
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L117-L130
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 100 |
[] | 0 | true | 98.165138 | 14 | 5 | 100 | 0 |
def register_middleware(self, middleware_instance):
registered_count = 0
self._middlewares.append(middleware_instance)
for hook in self._hooks:
functor = getattr(middleware_instance, hook, None)
if functor is None:
try:
functor = middleware_instance.get(hook, None)
except AttributeError:
pass
if functor is not None:
self._hooks[hook].append(functor)
registered_count += 1
return registered_count
| 22,520 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_resolve_endpoint
|
(self, endpoint)
|
return endpoint
| 135 | 138 |
def hook_resolve_endpoint(self, endpoint):
for functor in self._hooks['resolve_endpoint']:
endpoint = functor(endpoint)
return endpoint
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L135-L138
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.165138 | 4 | 2 | 100 | 0 |
def hook_resolve_endpoint(self, endpoint):
for functor in self._hooks['resolve_endpoint']:
endpoint = functor(endpoint)
return endpoint
| 22,521 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_load_task_context
|
(self, event_header)
| 140 | 142 |
def hook_load_task_context(self, event_header):
for functor in self._hooks['load_task_context']:
functor(event_header)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L140-L142
| 36 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 98.165138 | 3 | 2 | 100 | 0 |
def hook_load_task_context(self, event_header):
for functor in self._hooks['load_task_context']:
functor(event_header)
| 22,522 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_get_task_context
|
(self)
|
return event_header
| 144 | 148 |
def hook_get_task_context(self):
event_header = {}
for functor in self._hooks['get_task_context']:
event_header.update(functor())
return event_header
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L144-L148
| 36 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 98.165138 | 5 | 2 | 100 | 0 |
def hook_get_task_context(self):
event_header = {}
for functor in self._hooks['get_task_context']:
event_header.update(functor())
return event_header
| 22,523 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_server_before_exec
|
(self, request_event)
|
Called when a method is about to be executed on the server.
|
Called when a method is about to be executed on the server.
| 153 | 157 |
def hook_server_before_exec(self, request_event):
"""Called when a method is about to be executed on the server."""
for functor in self._hooks['server_before_exec']:
functor(request_event)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L153-L157
| 36 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 98.165138 | 5 | 2 | 100 | 1 |
def hook_server_before_exec(self, request_event):
for functor in self._hooks['server_before_exec']:
functor(request_event)
| 22,524 |
|
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_server_after_exec
|
(self, request_event, reply_event)
|
Called when a method has been executed successfully.
This hook is called right before the answer is sent back to the client.
If the method streams its answer (i.e: it uses the zerorpc.stream
decorator) then this hook will be called once the reply has been fully
streamed (and right before the stream is "closed").
The reply_event argument will be None if the Push/Pull pattern is used.
|
Called when a method has been executed successfully.
| 159 | 171 |
def hook_server_after_exec(self, request_event, reply_event):
"""Called when a method has been executed successfully.
This hook is called right before the answer is sent back to the client.
If the method streams its answer (i.e: it uses the zerorpc.stream
decorator) then this hook will be called once the reply has been fully
streamed (and right before the stream is "closed").
The reply_event argument will be None if the Push/Pull pattern is used.
"""
for functor in self._hooks['server_after_exec']:
functor(request_event, reply_event)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L159-L171
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
] | 100 |
[] | 0 | true | 98.165138 | 13 | 2 | 100 | 8 |
def hook_server_after_exec(self, request_event, reply_event):
for functor in self._hooks['server_after_exec']:
functor(request_event, reply_event)
| 22,525 |
|
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_server_inspect_exception
|
(self, request_event, reply_event, exc_infos)
|
Called when a method raised an exception.
The reply_event argument will be None if the Push/Pull pattern is used.
|
Called when a method raised an exception.
| 173 | 181 |
def hook_server_inspect_exception(self, request_event, reply_event, exc_infos):
"""Called when a method raised an exception.
The reply_event argument will be None if the Push/Pull pattern is used.
"""
task_context = self.hook_get_task_context()
for functor in self._hooks['server_inspect_exception']:
functor(request_event, reply_event, task_context, exc_infos)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L173-L181
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 98.165138 | 9 | 2 | 100 | 3 |
def hook_server_inspect_exception(self, request_event, reply_event, exc_infos):
task_context = self.hook_get_task_context()
for functor in self._hooks['server_inspect_exception']:
functor(request_event, reply_event, task_context, exc_infos)
| 22,526 |
|
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_client_handle_remote_error
|
(self, event)
|
return exception
| 186 | 192 |
def hook_client_handle_remote_error(self, event):
exception = None
for functor in self._hooks['client_handle_remote_error']:
ret = functor(event)
if ret:
exception = ret
return exception
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L186-L192
| 36 |
[
0,
1,
2,
3,
4,
5,
6
] | 100 |
[] | 0 | true | 98.165138 | 7 | 3 | 100 | 0 |
def hook_client_handle_remote_error(self, event):
exception = None
for functor in self._hooks['client_handle_remote_error']:
ret = functor(event)
if ret:
exception = ret
return exception
| 22,527 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_client_before_request
|
(self, event)
|
Called when the Client is about to send a request.
You can see it as the counterpart of ``hook_server_before_exec``.
|
Called when the Client is about to send a request.
| 194 | 201 |
def hook_client_before_request(self, event):
"""Called when the Client is about to send a request.
You can see it as the counterpart of ``hook_server_before_exec``.
"""
for functor in self._hooks['client_before_request']:
functor(event)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L194-L201
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 100 |
[] | 0 | true | 98.165138 | 8 | 2 | 100 | 3 |
def hook_client_before_request(self, event):
for functor in self._hooks['client_before_request']:
functor(event)
| 22,528 |
|
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_client_after_request
|
(self, request_event, reply_event, exception=None)
|
Called when an answer or a timeout has been received from the server.
This hook is called right before the answer is returned to the client.
You can see it as the counterpart of the ``hook_server_after_exec``.
If the called method was returning a stream (i.e: it uses the
zerorpc.stream decorator) then this hook will be called once the reply
has been fully streamed (when the stream is "closed") or when an
exception has been raised.
The optional exception argument will be a ``RemoteError`` (or whatever
type returned by the client_handle_remote_error hook) if an exception
has been raised on the server.
If the request timed out, then the exception argument will be a
``TimeoutExpired`` object and reply_event will be None.
|
Called when an answer or a timeout has been received from the server.
| 203 | 223 |
def hook_client_after_request(self, request_event, reply_event, exception=None):
"""Called when an answer or a timeout has been received from the server.
This hook is called right before the answer is returned to the client.
You can see it as the counterpart of the ``hook_server_after_exec``.
If the called method was returning a stream (i.e: it uses the
zerorpc.stream decorator) then this hook will be called once the reply
has been fully streamed (when the stream is "closed") or when an
exception has been raised.
The optional exception argument will be a ``RemoteError`` (or whatever
type returned by the client_handle_remote_error hook) if an exception
has been raised on the server.
If the request timed out, then the exception argument will be a
``TimeoutExpired`` object and reply_event will be None.
"""
for functor in self._hooks['client_after_request']:
functor(request_event, reply_event, exception)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L203-L223
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 |
[] | 0 | true | 98.165138 | 21 | 2 | 100 | 16 |
def hook_client_after_request(self, request_event, reply_event, exception=None):
for functor in self._hooks['client_after_request']:
functor(request_event, reply_event, exception)
| 22,529 |
|
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/context.py
|
Context.hook_client_patterns_list
|
(self, patterns)
|
return patterns
| 225 | 228 |
def hook_client_patterns_list(self, patterns):
for functor in self._hooks['client_patterns_list']:
patterns = functor(patterns)
return patterns
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/context.py#L225-L228
| 36 |
[
0,
1,
3
] | 75 |
[
2
] | 25 | false | 98.165138 | 4 | 2 | 75 | 0 |
def hook_client_patterns_list(self, patterns):
for functor in self._hooks['client_patterns_list']:
patterns = functor(patterns)
return patterns
| 22,530 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
SequentialSender.__init__
|
(self, socket)
| 62 | 63 |
def __init__(self, socket):
self._socket = socket
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L62-L63
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def __init__(self, socket):
self._socket = socket
| 22,531 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
SequentialSender._send
|
(self, parts)
| 65 | 79 |
def _send(self, parts):
e = None
for i in range(len(parts) - 1):
try:
self._socket.send(parts[i], copy=False, flags=zmq.SNDMORE)
except (gevent.GreenletExit, gevent.Timeout) as e:
if i == 0:
raise
self._socket.send(parts[i], copy=False, flags=zmq.SNDMORE)
try:
self._socket.send(parts[-1], copy=False)
except (gevent.GreenletExit, gevent.Timeout) as e:
self._socket.send(parts[-1], copy=False)
if e:
raise e
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L65-L79
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 94.795539 | 15 | 6 | 100 | 0 |
def _send(self, parts):
e = None
for i in range(len(parts) - 1):
try:
self._socket.send(parts[i], copy=False, flags=zmq.SNDMORE)
except (gevent.GreenletExit, gevent.Timeout) as e:
if i == 0:
raise
self._socket.send(parts[i], copy=False, flags=zmq.SNDMORE)
try:
self._socket.send(parts[-1], copy=False)
except (gevent.GreenletExit, gevent.Timeout) as e:
self._socket.send(parts[-1], copy=False)
if e:
raise e
| 22,532 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
SequentialSender.__call__
|
(self, parts, timeout=None)
| 81 | 86 |
def __call__(self, parts, timeout=None):
if timeout:
with gevent.Timeout(timeout):
self._send(parts)
else:
self._send(parts)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L81-L86
| 36 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 94.795539 | 6 | 3 | 100 | 0 |
def __call__(self, parts, timeout=None):
if timeout:
with gevent.Timeout(timeout):
self._send(parts)
else:
self._send(parts)
| 22,533 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
SequentialReceiver.__init__
|
(self, socket)
| 91 | 92 |
def __init__(self, socket):
self._socket = socket
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L91-L92
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def __init__(self, socket):
self._socket = socket
| 22,534 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
SequentialReceiver._recv
|
(self)
|
return parts
| 94 | 109 |
def _recv(self):
e = None
parts = []
while True:
try:
part = self._socket.recv(copy=False)
except (gevent.GreenletExit, gevent.Timeout) as e:
if len(parts) == 0:
raise
part = self._socket.recv(copy=False)
parts.append(part)
if not part.more:
break
if e:
raise e
return parts
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L94-L109
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 |
[] | 0 | true | 94.795539 | 16 | 6 | 100 | 0 |
def _recv(self):
e = None
parts = []
while True:
try:
part = self._socket.recv(copy=False)
except (gevent.GreenletExit, gevent.Timeout) as e:
if len(parts) == 0:
raise
part = self._socket.recv(copy=False)
parts.append(part)
if not part.more:
break
if e:
raise e
return parts
| 22,535 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
SequentialReceiver.__call__
|
(self, timeout=None)
| 111 | 116 |
def __call__(self, timeout=None):
if timeout:
with gevent.Timeout(timeout):
return self._recv()
else:
return self._recv()
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L111-L116
| 36 |
[
0,
1,
3,
4,
5
] | 83.333333 |
[
2
] | 16.666667 | false | 94.795539 | 6 | 3 | 83.333333 | 0 |
def __call__(self, timeout=None):
if timeout:
with gevent.Timeout(timeout):
return self._recv()
else:
return self._recv()
| 22,536 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Sender.__init__
|
(self, socket)
| 121 | 124 |
def __init__(self, socket):
self._socket = socket
self._send_queue = gevent.queue.Channel()
self._send_task = gevent.spawn(self._sender)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L121-L124
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 94.795539 | 4 | 1 | 100 | 0 |
def __init__(self, socket):
self._socket = socket
self._send_queue = gevent.queue.Channel()
self._send_task = gevent.spawn(self._sender)
| 22,537 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Sender.close
|
(self)
| 126 | 128 |
def close(self):
if self._send_task:
self._send_task.kill()
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L126-L128
| 36 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 94.795539 | 3 | 2 | 100 | 0 |
def close(self):
if self._send_task:
self._send_task.kill()
| 22,538 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Sender._sender
|
(self)
| 130 | 132 |
def _sender(self):
for parts in self._send_queue:
super(Sender, self)._send(parts)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L130-L132
| 36 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 94.795539 | 3 | 2 | 100 | 0 |
def _sender(self):
for parts in self._send_queue:
super(Sender, self)._send(parts)
| 22,539 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Sender.__call__
|
(self, parts, timeout=None)
| 134 | 138 |
def __call__(self, parts, timeout=None):
try:
self._send_queue.put(parts, timeout=timeout)
except gevent.queue.Full:
raise TimeoutExpired(timeout)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L134-L138
| 36 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 94.795539 | 5 | 2 | 100 | 0 |
def __call__(self, parts, timeout=None):
try:
self._send_queue.put(parts, timeout=timeout)
except gevent.queue.Full:
raise TimeoutExpired(timeout)
| 22,540 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Receiver.__init__
|
(self, socket)
| 143 | 146 |
def __init__(self, socket):
self._socket = socket
self._recv_queue = gevent.queue.Channel()
self._recv_task = gevent.spawn(self._recver)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L143-L146
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 94.795539 | 4 | 1 | 100 | 0 |
def __init__(self, socket):
self._socket = socket
self._recv_queue = gevent.queue.Channel()
self._recv_task = gevent.spawn(self._recver)
| 22,541 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Receiver.close
|
(self)
| 148 | 151 |
def close(self):
if self._recv_task:
self._recv_task.kill()
self._recv_queue = None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L148-L151
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 94.795539 | 4 | 2 | 100 | 0 |
def close(self):
if self._recv_task:
self._recv_task.kill()
self._recv_queue = None
| 22,542 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Receiver._recver
|
(self)
| 153 | 156 |
def _recver(self):
while True:
parts = super(Receiver, self)._recv()
self._recv_queue.put(parts)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L153-L156
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 94.795539 | 4 | 2 | 100 | 0 |
def _recver(self):
while True:
parts = super(Receiver, self)._recv()
self._recv_queue.put(parts)
| 22,543 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Receiver.__call__
|
(self, timeout=None)
| 158 | 162 |
def __call__(self, timeout=None):
try:
return self._recv_queue.get(timeout=timeout)
except gevent.queue.Empty:
raise TimeoutExpired(timeout)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L158-L162
| 36 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 94.795539 | 5 | 2 | 100 | 0 |
def __call__(self, timeout=None):
try:
return self._recv_queue.get(timeout=timeout)
except gevent.queue.Empty:
raise TimeoutExpired(timeout)
| 22,544 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.__init__
|
(self, name, args, context, header=None)
| 173 | 180 |
def __init__(self, name, args, context, header=None):
self._name = name
self._args = args
if header is None:
self._header = {u'message_id': context.new_msgid(), u'v': 3}
else:
self._header = header
self._identity = None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L173-L180
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 100 |
[] | 0 | true | 94.795539 | 8 | 2 | 100 | 0 |
def __init__(self, name, args, context, header=None):
self._name = name
self._args = args
if header is None:
self._header = {u'message_id': context.new_msgid(), u'v': 3}
else:
self._header = header
self._identity = None
| 22,545 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.header
|
(self)
|
return self._header
| 183 | 184 |
def header(self):
return self._header
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L183-L184
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def header(self):
return self._header
| 22,546 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.name
|
(self)
|
return self._name
| 187 | 188 |
def name(self):
return self._name
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L187-L188
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def name(self):
return self._name
| 22,547 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.name
|
(self, v)
| 191 | 192 |
def name(self, v):
self._name = v
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L191-L192
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def name(self, v):
self._name = v
| 22,548 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.args
|
(self)
|
return self._args
| 195 | 196 |
def args(self):
return self._args
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L195-L196
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def args(self):
return self._args
| 22,549 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.identity
|
(self)
|
return self._identity
| 199 | 200 |
def identity(self):
return self._identity
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L199-L200
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def identity(self):
return self._identity
| 22,550 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.identity
|
(self, v)
| 203 | 204 |
def identity(self, v):
self._identity = v
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L203-L204
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def identity(self, v):
self._identity = v
| 22,551 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.pack
|
(self)
|
return r
| 206 | 209 |
def pack(self):
payload = (self._header, self._name, self._args)
r = msgpack.Packer(use_bin_type=True).pack(payload)
return r
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L206-L209
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 94.795539 | 4 | 1 | 100 | 0 |
def pack(self):
payload = (self._header, self._name, self._args)
r = msgpack.Packer(use_bin_type=True).pack(payload)
return r
| 22,552 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.unpack
|
(blob)
|
return Event(name, args, None, header)
| 212 | 227 |
def unpack(blob):
unpacker = msgpack.Unpacker(raw=False)
unpacker.feed(blob)
unpacked_msg = unpacker.unpack()
try:
(header, name, args) = unpacked_msg
except Exception as e:
raise Exception('invalid msg format "{0}": {1}'.format(
unpacked_msg, e))
# Backward compatibility
if not isinstance(header, dict):
header = {}
return Event(name, args, None, header)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L212-L227
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
11,
12,
14,
15
] | 87.5 |
[
13
] | 6.25 | false | 94.795539 | 16 | 3 | 93.75 | 0 |
def unpack(blob):
unpacker = msgpack.Unpacker(raw=False)
unpacker.feed(blob)
unpacked_msg = unpacker.unpack()
try:
(header, name, args) = unpacked_msg
except Exception as e:
raise Exception('invalid msg format "{0}": {1}'.format(
unpacked_msg, e))
# Backward compatibility
if not isinstance(header, dict):
header = {}
return Event(name, args, None, header)
| 22,553 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Event.__str__
|
(self, ignore_args=False)
|
return '{0} {1} {2}'.format(self._name, self._header, args)
| 229 | 242 |
def __str__(self, ignore_args=False):
if ignore_args:
args = '[...]'
else:
args = self._args
try:
args = '<<{0}>>'.format(str(self.unpack(self._args)))
except Exception:
pass
if self._identity:
identity = ', '.join(repr(x.bytes) for x in self._identity)
return '<{0}> {1} {2} {3}'.format(identity, self._name,
self._header, args)
return '{0} {1} {2}'.format(self._name, self._header, args)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L229-L242
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
13
] | 92.857143 |
[] | 0 | false | 94.795539 | 14 | 4 | 100 | 0 |
def __str__(self, ignore_args=False):
if ignore_args:
args = '[...]'
else:
args = self._args
try:
args = '<<{0}>>'.format(str(self.unpack(self._args)))
except Exception:
pass
if self._identity:
identity = ', '.join(repr(x.bytes) for x in self._identity)
return '<{0}> {1} {2} {3}'.format(identity, self._name,
self._header, args)
return '{0} {1} {2}'.format(self._name, self._header, args)
| 22,554 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.__init__
|
(self, zmq_socket_type, context=None)
| 246 | 264 |
def __init__(self, zmq_socket_type, context=None):
self._debug = False
self._zmq_socket_type = zmq_socket_type
self._context = context or Context.get_instance()
self._socket = self._context.socket(zmq_socket_type)
if zmq_socket_type in (zmq.PUSH, zmq.PUB, zmq.DEALER, zmq.ROUTER):
self._send = Sender(self._socket)
elif zmq_socket_type in (zmq.REQ, zmq.REP):
self._send = SequentialSender(self._socket)
else:
self._send = None
if zmq_socket_type in (zmq.PULL, zmq.SUB, zmq.DEALER, zmq.ROUTER):
self._recv = Receiver(self._socket)
elif zmq_socket_type in (zmq.REQ, zmq.REP):
self._recv = SequentialReceiver(self._socket)
else:
self._recv = None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L246-L264
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
18
] | 94.736842 |
[] | 0 | false | 94.795539 | 19 | 6 | 100 | 0 |
def __init__(self, zmq_socket_type, context=None):
self._debug = False
self._zmq_socket_type = zmq_socket_type
self._context = context or Context.get_instance()
self._socket = self._context.socket(zmq_socket_type)
if zmq_socket_type in (zmq.PUSH, zmq.PUB, zmq.DEALER, zmq.ROUTER):
self._send = Sender(self._socket)
elif zmq_socket_type in (zmq.REQ, zmq.REP):
self._send = SequentialSender(self._socket)
else:
self._send = None
if zmq_socket_type in (zmq.PULL, zmq.SUB, zmq.DEALER, zmq.ROUTER):
self._recv = Receiver(self._socket)
elif zmq_socket_type in (zmq.REQ, zmq.REP):
self._recv = SequentialReceiver(self._socket)
else:
self._recv = None
| 22,555 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.recv_is_supported
|
(self)
|
return self._recv is not None
| 267 | 268 |
def recv_is_supported(self):
return self._recv is not None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L267-L268
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def recv_is_supported(self):
return self._recv is not None
| 22,556 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.emit_is_supported
|
(self)
|
return self._send is not None
| 271 | 272 |
def emit_is_supported(self):
return self._send is not None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L271-L272
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def emit_is_supported(self):
return self._send is not None
| 22,557 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.__del__
|
(self)
| 274 | 279 |
def __del__(self):
try:
if not self._socket.closed:
self.close()
except (AttributeError, TypeError):
pass
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L274-L279
| 36 |
[
0,
1,
2,
3,
4
] | 83.333333 |
[
5
] | 16.666667 | false | 94.795539 | 6 | 3 | 83.333333 | 0 |
def __del__(self):
try:
if not self._socket.closed:
self.close()
except (AttributeError, TypeError):
pass
| 22,558 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.close
|
(self)
| 281 | 290 |
def close(self):
try:
self._send.close()
except (AttributeError, TypeError, gevent.GreenletExit):
pass
try:
self._recv.close()
except (AttributeError, TypeError, gevent.GreenletExit):
pass
self._socket.close()
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L281-L290
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 94.795539 | 10 | 3 | 100 | 0 |
def close(self):
try:
self._send.close()
except (AttributeError, TypeError, gevent.GreenletExit):
pass
try:
self._recv.close()
except (AttributeError, TypeError, gevent.GreenletExit):
pass
self._socket.close()
| 22,559 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.debug
|
(self)
|
return self._debug
| 293 | 294 |
def debug(self):
return self._debug
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L293-L294
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def debug(self):
return self._debug
| 22,560 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.debug
|
(self, v)
| 297 | 303 |
def debug(self, v):
if v != self._debug:
self._debug = v
if self._debug:
logger.debug('debug enabled')
else:
logger.debug('debug disabled')
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L297-L303
| 36 |
[
0,
1,
2,
4
] | 57.142857 |
[
3,
6
] | 28.571429 | false | 94.795539 | 7 | 3 | 71.428571 | 0 |
def debug(self, v):
if v != self._debug:
self._debug = v
if self._debug:
logger.debug('debug enabled')
else:
logger.debug('debug disabled')
| 22,561 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events._resolve_endpoint
|
(self, endpoint, resolve=True)
|
return [endpoint]
| 305 | 313 |
def _resolve_endpoint(self, endpoint, resolve=True):
if resolve:
endpoint = self._context.hook_resolve_endpoint(endpoint)
if isinstance(endpoint, (tuple, list)):
r = []
for sub_endpoint in endpoint:
r.extend(self._resolve_endpoint(sub_endpoint, resolve))
return r
return [endpoint]
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L305-L313
| 36 |
[
0,
1,
2,
3,
8
] | 55.555556 |
[
4,
5,
6,
7
] | 44.444444 | false | 94.795539 | 9 | 4 | 55.555556 | 0 |
def _resolve_endpoint(self, endpoint, resolve=True):
if resolve:
endpoint = self._context.hook_resolve_endpoint(endpoint)
if isinstance(endpoint, (tuple, list)):
r = []
for sub_endpoint in endpoint:
r.extend(self._resolve_endpoint(sub_endpoint, resolve))
return r
return [endpoint]
| 22,562 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.connect
|
(self, endpoint, resolve=True)
|
return r
| 315 | 320 |
def connect(self, endpoint, resolve=True):
r = []
for endpoint_ in self._resolve_endpoint(endpoint, resolve):
r.append(self._socket.connect(endpoint_))
logger.debug('connected to %s (status=%s)', endpoint_, r[-1])
return r
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L315-L320
| 36 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 94.795539 | 6 | 2 | 100 | 0 |
def connect(self, endpoint, resolve=True):
r = []
for endpoint_ in self._resolve_endpoint(endpoint, resolve):
r.append(self._socket.connect(endpoint_))
logger.debug('connected to %s (status=%s)', endpoint_, r[-1])
return r
| 22,563 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.bind
|
(self, endpoint, resolve=True)
|
return r
| 322 | 327 |
def bind(self, endpoint, resolve=True):
r = []
for endpoint_ in self._resolve_endpoint(endpoint, resolve):
r.append(self._socket.bind(endpoint_))
logger.debug('bound to %s (status=%s)', endpoint_, r[-1])
return r
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L322-L327
| 36 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 94.795539 | 6 | 2 | 100 | 0 |
def bind(self, endpoint, resolve=True):
r = []
for endpoint_ in self._resolve_endpoint(endpoint, resolve):
r.append(self._socket.bind(endpoint_))
logger.debug('bound to %s (status=%s)', endpoint_, r[-1])
return r
| 22,564 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.disconnect
|
(self, endpoint, resolve=True)
|
return r
| 329 | 334 |
def disconnect(self, endpoint, resolve=True):
r = []
for endpoint_ in self._resolve_endpoint(endpoint, resolve):
r.append(self._socket.disconnect(endpoint_))
logger.debug('disconnected from %s (status=%s)', endpoint_, r[-1])
return r
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L329-L334
| 36 |
[
0,
2,
3,
4
] | 66.666667 |
[
1,
5
] | 33.333333 | false | 94.795539 | 6 | 2 | 66.666667 | 0 |
def disconnect(self, endpoint, resolve=True):
r = []
for endpoint_ in self._resolve_endpoint(endpoint, resolve):
r.append(self._socket.disconnect(endpoint_))
logger.debug('disconnected from %s (status=%s)', endpoint_, r[-1])
return r
| 22,565 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.new_event
|
(self, name, args, xheader=None)
|
return event
| 336 | 340 |
def new_event(self, name, args, xheader=None):
event = Event(name, args, context=self._context)
if xheader:
event.header.update(xheader)
return event
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L336-L340
| 36 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 94.795539 | 5 | 2 | 100 | 0 |
def new_event(self, name, args, xheader=None):
event = Event(name, args, context=self._context)
if xheader:
event.header.update(xheader)
return event
| 22,566 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.emit_event
|
(self, event, timeout=None)
| 342 | 352 |
def emit_event(self, event, timeout=None):
if self._debug:
logger.debug('--> %s', event)
if event.identity:
parts = list(event.identity or list())
parts.extend([b'', event.pack()])
elif self._zmq_socket_type in (zmq.DEALER, zmq.ROUTER):
parts = (b'', event.pack())
else:
parts = (event.pack(),)
self._send(parts, timeout)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L342-L352
| 36 |
[
0,
1,
3,
4,
5,
6,
7,
8,
9,
10
] | 90.909091 |
[
2
] | 9.090909 | false | 94.795539 | 11 | 5 | 90.909091 | 0 |
def emit_event(self, event, timeout=None):
if self._debug:
logger.debug('--> %s', event)
if event.identity:
parts = list(event.identity or list())
parts.extend([b'', event.pack()])
elif self._zmq_socket_type in (zmq.DEALER, zmq.ROUTER):
parts = (b'', event.pack())
else:
parts = (event.pack(),)
self._send(parts, timeout)
| 22,567 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.recv
|
(self, timeout=None)
|
return event
| 354 | 369 |
def recv(self, timeout=None):
parts = self._recv(timeout=timeout)
if len(parts) > 2:
identity = parts[0:-2]
blob = parts[-1]
elif len(parts) == 2:
identity = parts[0:-1]
blob = parts[-1]
else:
identity = None
blob = parts[0]
event = Event.unpack(get_pyzmq_frame_buffer(blob))
event.identity = identity
if self._debug:
logger.debug('<-- %s', event)
return event
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L354-L369
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 |
[] | 0 | true | 94.795539 | 16 | 4 | 100 | 0 |
def recv(self, timeout=None):
parts = self._recv(timeout=timeout)
if len(parts) > 2:
identity = parts[0:-2]
blob = parts[-1]
elif len(parts) == 2:
identity = parts[0:-1]
blob = parts[-1]
else:
identity = None
blob = parts[0]
event = Event.unpack(get_pyzmq_frame_buffer(blob))
event.identity = identity
if self._debug:
logger.debug('<-- %s', event)
return event
| 22,568 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.setsockopt
|
(self, *args)
|
return self._socket.setsockopt(*args)
| 371 | 372 |
def setsockopt(self, *args):
return self._socket.setsockopt(*args)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L371-L372
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def setsockopt(self, *args):
return self._socket.setsockopt(*args)
| 22,569 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/events.py
|
Events.context
|
(self)
|
return self._context
| 375 | 376 |
def context(self):
return self._context
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/events.py#L375-L376
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 94.795539 | 2 | 1 | 100 | 0 |
def context(self):
return self._context
| 22,570 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.__init__
|
(self, events, ignore_broadcast=False)
| 40 | 48 |
def __init__(self, events, ignore_broadcast=False):
self._events = events
self._active_channels = {}
self._channel_dispatcher_task = None
self._broadcast_queue = None
if events.recv_is_supported and not ignore_broadcast:
self._broadcast_queue = gevent.queue.Queue(maxsize=1)
self._channel_dispatcher_task = gevent.spawn(
self._channel_dispatcher)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L40-L48
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 88.888889 |
[] | 0 | false | 86.096257 | 9 | 3 | 100 | 0 |
def __init__(self, events, ignore_broadcast=False):
self._events = events
self._active_channels = {}
self._channel_dispatcher_task = None
self._broadcast_queue = None
if events.recv_is_supported and not ignore_broadcast:
self._broadcast_queue = gevent.queue.Queue(maxsize=1)
self._channel_dispatcher_task = gevent.spawn(
self._channel_dispatcher)
| 22,571 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.recv_is_supported
|
(self)
|
return self._events.recv_is_supported
| 51 | 52 |
def recv_is_supported(self):
return self._events.recv_is_supported
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L51-L52
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def recv_is_supported(self):
return self._events.recv_is_supported
| 22,572 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.emit_is_supported
|
(self)
|
return self._events.emit_is_supported
| 55 | 56 |
def emit_is_supported(self):
return self._events.emit_is_supported
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L55-L56
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def emit_is_supported(self):
return self._events.emit_is_supported
| 22,573 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.close
|
(self)
| 58 | 60 |
def close(self):
if self._channel_dispatcher_task:
self._channel_dispatcher_task.kill()
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L58-L60
| 36 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 86.096257 | 3 | 2 | 100 | 0 |
def close(self):
if self._channel_dispatcher_task:
self._channel_dispatcher_task.kill()
| 22,574 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.new_event
|
(self, name, args, xheader=None)
|
return self._events.new_event(name, args, xheader)
| 62 | 63 |
def new_event(self, name, args, xheader=None):
return self._events.new_event(name, args, xheader)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L62-L63
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def new_event(self, name, args, xheader=None):
return self._events.new_event(name, args, xheader)
| 22,575 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.emit_event
|
(self, event, timeout=None)
|
return self._events.emit_event(event, timeout)
| 65 | 66 |
def emit_event(self, event, timeout=None):
return self._events.emit_event(event, timeout)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L65-L66
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def emit_event(self, event, timeout=None):
return self._events.emit_event(event, timeout)
| 22,576 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.recv
|
(self, timeout=None)
|
return event
| 68 | 73 |
def recv(self, timeout=None):
if self._broadcast_queue is not None:
event = self._broadcast_queue.get(timeout=timeout)
else:
event = self._events.recv(timeout=timeout)
return event
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L68-L73
| 36 |
[
0,
1,
2,
3,
4
] | 83.333333 |
[
5
] | 16.666667 | false | 86.096257 | 6 | 2 | 83.333333 | 0 |
def recv(self, timeout=None):
if self._broadcast_queue is not None:
event = self._broadcast_queue.get(timeout=timeout)
else:
event = self._events.recv(timeout=timeout)
return event
| 22,577 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer._channel_dispatcher
|
(self)
| 75 | 97 |
def _channel_dispatcher(self):
while True:
try:
event = self._events.recv()
except Exception:
logger.exception('zerorpc.ChannelMultiplexer ignoring error on recv')
continue
channel_id = event.header.get(u'response_to', None)
queue = None
if channel_id is not None:
channel = self._active_channels.get(channel_id, None)
if channel is not None:
queue = channel._queue
elif self._broadcast_queue is not None:
queue = self._broadcast_queue
if queue is None:
logger.warning('zerorpc.ChannelMultiplexer,'
' unable to route event: {0}'.format(
event.__str__(ignore_args=True)))
else:
queue.put(event)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L75-L97
| 36 |
[
0,
1,
2,
3,
4,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
22
] | 78.26087 |
[
5,
6
] | 8.695652 | false | 86.096257 | 23 | 7 | 91.304348 | 0 |
def _channel_dispatcher(self):
while True:
try:
event = self._events.recv()
except Exception:
logger.exception('zerorpc.ChannelMultiplexer ignoring error on recv')
continue
channel_id = event.header.get(u'response_to', None)
queue = None
if channel_id is not None:
channel = self._active_channels.get(channel_id, None)
if channel is not None:
queue = channel._queue
elif self._broadcast_queue is not None:
queue = self._broadcast_queue
if queue is None:
logger.warning('zerorpc.ChannelMultiplexer,'
' unable to route event: {0}'.format(
event.__str__(ignore_args=True)))
else:
queue.put(event)
| 22,578 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.channel
|
(self, from_event=None)
|
return Channel(self, from_event)
| 99 | 103 |
def channel(self, from_event=None):
if self._channel_dispatcher_task is None:
self._channel_dispatcher_task = gevent.spawn(
self._channel_dispatcher)
return Channel(self, from_event)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L99-L103
| 36 |
[
0,
1,
2,
4
] | 80 |
[] | 0 | false | 86.096257 | 5 | 2 | 100 | 0 |
def channel(self, from_event=None):
if self._channel_dispatcher_task is None:
self._channel_dispatcher_task = gevent.spawn(
self._channel_dispatcher)
return Channel(self, from_event)
| 22,579 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.active_channels
|
(self)
|
return self._active_channels
| 106 | 107 |
def active_channels(self):
return self._active_channels
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L106-L107
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def active_channels(self):
return self._active_channels
| 22,580 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
ChannelMultiplexer.context
|
(self)
|
return self._events.context
| 110 | 111 |
def context(self):
return self._events.context
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L110-L111
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def context(self):
return self._events.context
| 22,581 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.__init__
|
(self, multiplexer, from_event=None)
| 116 | 126 |
def __init__(self, multiplexer, from_event=None):
self._multiplexer = multiplexer
self._channel_id = None
self._zmqid = None
self._queue = gevent.queue.Queue(maxsize=1)
if from_event is not None:
self._channel_id = from_event.header[u'message_id']
self._zmqid = from_event.identity
self._multiplexer._active_channels[self._channel_id] = self
logger.debug('<-- new channel %s', self._channel_id)
self._queue.put(from_event)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L116-L126
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 100 |
[] | 0 | true | 86.096257 | 11 | 2 | 100 | 0 |
def __init__(self, multiplexer, from_event=None):
self._multiplexer = multiplexer
self._channel_id = None
self._zmqid = None
self._queue = gevent.queue.Queue(maxsize=1)
if from_event is not None:
self._channel_id = from_event.header[u'message_id']
self._zmqid = from_event.identity
self._multiplexer._active_channels[self._channel_id] = self
logger.debug('<-- new channel %s', self._channel_id)
self._queue.put(from_event)
| 22,582 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.recv_is_supported
|
(self)
|
return self._multiplexer.recv_is_supported
| 129 | 130 |
def recv_is_supported(self):
return self._multiplexer.recv_is_supported
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L129-L130
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def recv_is_supported(self):
return self._multiplexer.recv_is_supported
| 22,583 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.emit_is_supported
|
(self)
|
return self._multiplexer.emit_is_supported
| 133 | 134 |
def emit_is_supported(self):
return self._multiplexer.emit_is_supported
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L133-L134
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def emit_is_supported(self):
return self._multiplexer.emit_is_supported
| 22,584 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.close
|
(self)
| 136 | 140 |
def close(self):
if self._channel_id is not None:
del self._multiplexer._active_channels[self._channel_id]
logger.debug('-x- closed channel %s', self._channel_id)
self._channel_id = None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L136-L140
| 36 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 86.096257 | 5 | 2 | 100 | 0 |
def close(self):
if self._channel_id is not None:
del self._multiplexer._active_channels[self._channel_id]
logger.debug('-x- closed channel %s', self._channel_id)
self._channel_id = None
| 22,585 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.new_event
|
(self, name, args, xheader=None)
|
return event
| 142 | 151 |
def new_event(self, name, args, xheader=None):
event = self._multiplexer.new_event(name, args, xheader)
if self._channel_id is None:
self._channel_id = event.header[u'message_id']
self._multiplexer._active_channels[self._channel_id] = self
logger.debug('--> new channel %s', self._channel_id)
else:
event.header[u'response_to'] = self._channel_id
event.identity = self._zmqid
return event
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L142-L151
| 36 |
[
0,
1,
2,
3,
4,
5,
7,
8,
9
] | 90 |
[] | 0 | false | 86.096257 | 10 | 2 | 100 | 0 |
def new_event(self, name, args, xheader=None):
event = self._multiplexer.new_event(name, args, xheader)
if self._channel_id is None:
self._channel_id = event.header[u'message_id']
self._multiplexer._active_channels[self._channel_id] = self
logger.debug('--> new channel %s', self._channel_id)
else:
event.header[u'response_to'] = self._channel_id
event.identity = self._zmqid
return event
| 22,586 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.emit_event
|
(self, event, timeout=None)
| 153 | 154 |
def emit_event(self, event, timeout=None):
self._multiplexer.emit_event(event, timeout)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L153-L154
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def emit_event(self, event, timeout=None):
self._multiplexer.emit_event(event, timeout)
| 22,587 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.recv
|
(self, timeout=None)
|
return event
| 156 | 161 |
def recv(self, timeout=None):
try:
event = self._queue.get(timeout=timeout)
except gevent.queue.Empty:
raise TimeoutExpired(timeout)
return event
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L156-L161
| 36 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 86.096257 | 6 | 2 | 100 | 0 |
def recv(self, timeout=None):
try:
event = self._queue.get(timeout=timeout)
except gevent.queue.Empty:
raise TimeoutExpired(timeout)
return event
| 22,588 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
Channel.context
|
(self)
|
return self._multiplexer.context
| 164 | 165 |
def context(self):
return self._multiplexer.context
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L164-L165
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def context(self):
return self._multiplexer.context
| 22,589 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.__init__
|
(self, channel, inqueue_size=100)
| 170 | 179 |
def __init__(self, channel, inqueue_size=100):
self._channel = channel
self._input_queue_size = inqueue_size
self._remote_queue_open_slots = 1
self._input_queue_reserved = 1
self._remote_can_recv = gevent.event.Event()
self._input_queue = gevent.queue.Queue()
self._verbose = False
self._on_close_if = None
self._recv_task = gevent.spawn(self._recver)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L170-L179
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 86.096257 | 10 | 1 | 100 | 0 |
def __init__(self, channel, inqueue_size=100):
self._channel = channel
self._input_queue_size = inqueue_size
self._remote_queue_open_slots = 1
self._input_queue_reserved = 1
self._remote_can_recv = gevent.event.Event()
self._input_queue = gevent.queue.Queue()
self._verbose = False
self._on_close_if = None
self._recv_task = gevent.spawn(self._recver)
| 22,590 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.recv_is_supported
|
(self)
|
return self._channel.recv_is_supported
| 182 | 183 |
def recv_is_supported(self):
return self._channel.recv_is_supported
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L182-L183
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def recv_is_supported(self):
return self._channel.recv_is_supported
| 22,591 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.emit_is_supported
|
(self)
|
return self._channel.emit_is_supported
| 186 | 187 |
def emit_is_supported(self):
return self._channel.emit_is_supported
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L186-L187
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def emit_is_supported(self):
return self._channel.emit_is_supported
| 22,592 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.on_close_if
|
(self)
|
return self._on_close_if
| 190 | 191 |
def on_close_if(self):
return self._on_close_if
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L190-L191
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def on_close_if(self):
return self._on_close_if
| 22,593 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.on_close_if
|
(self, cb)
| 194 | 195 |
def on_close_if(self, cb):
self._on_close_if = cb
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L194-L195
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def on_close_if(self, cb):
self._on_close_if = cb
| 22,594 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.close
|
(self)
| 197 | 203 |
def close(self):
if self._recv_task is not None:
self._recv_task.kill()
self._recv_task = None
if self._channel is not None:
self._channel.close()
self._channel = None
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L197-L203
| 36 |
[
0,
1,
2,
3,
4,
5,
6
] | 100 |
[] | 0 | true | 86.096257 | 7 | 3 | 100 | 0 |
def close(self):
if self._recv_task is not None:
self._recv_task.kill()
self._recv_task = None
if self._channel is not None:
self._channel.close()
self._channel = None
| 22,595 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel._recver
|
(self)
| 205 | 223 |
def _recver(self):
while True:
event = self._channel.recv()
if event.name == u'_zpc_more':
try:
self._remote_queue_open_slots += int(event.args[0])
except Exception:
logger.exception('gevent_zerorpc.BufferedChannel._recver')
if self._remote_queue_open_slots > 0:
self._remote_can_recv.set()
elif self._input_queue.qsize() == self._input_queue_size:
raise RuntimeError(
'BufferedChannel, queue overflow on event:', event)
else:
self._input_queue.put(event)
if self._on_close_if is not None and self._on_close_if(event):
self._recv_task = None
self.close()
return
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L205-L223
| 36 |
[
0,
1,
2,
3,
10,
13,
14,
15
] | 42.105263 |
[
4,
5,
6,
7,
8,
9,
11,
16,
17,
18
] | 52.631579 | false | 86.096257 | 19 | 8 | 47.368421 | 0 |
def _recver(self):
while True:
event = self._channel.recv()
if event.name == u'_zpc_more':
try:
self._remote_queue_open_slots += int(event.args[0])
except Exception:
logger.exception('gevent_zerorpc.BufferedChannel._recver')
if self._remote_queue_open_slots > 0:
self._remote_can_recv.set()
elif self._input_queue.qsize() == self._input_queue_size:
raise RuntimeError(
'BufferedChannel, queue overflow on event:', event)
else:
self._input_queue.put(event)
if self._on_close_if is not None and self._on_close_if(event):
self._recv_task = None
self.close()
return
| 22,596 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.new_event
|
(self, name, args, xheader=None)
|
return self._channel.new_event(name, args, xheader)
| 225 | 226 |
def new_event(self, name, args, xheader=None):
return self._channel.new_event(name, args, xheader)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L225-L226
| 36 |
[
0,
1
] | 100 |
[] | 0 | true | 86.096257 | 2 | 1 | 100 | 0 |
def new_event(self, name, args, xheader=None):
return self._channel.new_event(name, args, xheader)
| 22,597 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.emit_event
|
(self, event, timeout=None)
| 228 | 237 |
def emit_event(self, event, timeout=None):
if self._remote_queue_open_slots == 0:
self._remote_can_recv.clear()
self._remote_can_recv.wait(timeout=timeout)
self._remote_queue_open_slots -= 1
try:
self._channel.emit_event(event)
except:
self._remote_queue_open_slots += 1
raise
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L228-L237
| 36 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7,
8,
9
] | 30 | false | 86.096257 | 10 | 3 | 70 | 0 |
def emit_event(self, event, timeout=None):
if self._remote_queue_open_slots == 0:
self._remote_can_recv.clear()
self._remote_can_recv.wait(timeout=timeout)
self._remote_queue_open_slots -= 1
try:
self._channel.emit_event(event)
except:
self._remote_queue_open_slots += 1
raise
| 22,598 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel._request_data
|
(self)
| 239 | 242 |
def _request_data(self):
open_slots = self._input_queue_size - self._input_queue_reserved
self._input_queue_reserved += open_slots
self._channel.emit(u'_zpc_more', (open_slots,))
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L239-L242
| 36 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 86.096257 | 4 | 1 | 100 | 0 |
def _request_data(self):
open_slots = self._input_queue_size - self._input_queue_reserved
self._input_queue_reserved += open_slots
self._channel.emit(u'_zpc_more', (open_slots,))
| 22,599 |
|||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.recv
|
(self, timeout=None)
|
return event
| 244 | 260 |
def recv(self, timeout=None):
# self._channel can be set to None by an 'on_close_if' callback if it
# sees a suitable message from the remote end...
#
if self._verbose and self._channel:
if self._input_queue_reserved < self._input_queue_size // 2:
self._request_data()
else:
self._verbose = True
try:
event = self._input_queue.get(timeout=timeout)
except gevent.queue.Empty:
raise TimeoutExpired(timeout)
self._input_queue_reserved -= 1
return event
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L244-L260
| 36 |
[
0,
1,
2,
3,
4,
5,
6,
8,
9,
10,
11,
14,
15,
16
] | 82.352941 |
[
12,
13
] | 11.764706 | false | 86.096257 | 17 | 5 | 88.235294 | 0 |
def recv(self, timeout=None):
# self._channel can be set to None by an 'on_close_if' callback if it
# sees a suitable message from the remote end...
#
if self._verbose and self._channel:
if self._input_queue_reserved < self._input_queue_size // 2:
self._request_data()
else:
self._verbose = True
try:
event = self._input_queue.get(timeout=timeout)
except gevent.queue.Empty:
raise TimeoutExpired(timeout)
self._input_queue_reserved -= 1
return event
| 22,600 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.channel
|
(self)
|
return self._channel
| 263 | 264 |
def channel(self):
return self._channel
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L263-L264
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def channel(self):
return self._channel
| 22,601 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/channel.py
|
BufferedChannel.context
|
(self)
|
return self._channel.context
| 267 | 268 |
def context(self):
return self._channel.context
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/channel.py#L267-L268
| 36 |
[
0
] | 50 |
[
1
] | 50 | false | 86.096257 | 2 | 1 | 50 | 0 |
def context(self):
return self._channel.context
| 22,602 |
||
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/core.py
|
fork_task_context
|
(functor, context=None)
|
return wrapped
|
Wrap a functor to transfer context.
Usage example:
gevent.spawn(zerorpc.fork_task_context(myfunction), args...)
The goal is to permit context "inheritance" from a task to another.
Consider the following example:
zerorpc.Server receive a new event
- task1 is created to handle this event this task will be linked
to the initial event context. zerorpc.Server does that for you.
- task1 make use of some zerorpc.Client instances, the initial
event context is transfered on every call.
- task1 spawn a new task2.
- task2 make use of some zerorpc.Client instances, it's a fresh
context. Thus there is no link to the initial context that
spawned task1.
- task1 spawn a new fork_task_context(task3).
- task3 make use of some zerorpc.Client instances, the initial
event context is transfered on every call.
A real use case is a distributed tracer. Each time a new event is
created, a trace_id is injected in it or copied from the current task
context. This permit passing the trace_id from a zerorpc.Server to
another via zerorpc.Client.
The simple rule to know if a task need to be wrapped is:
- if the new task will make any zerorpc call, it should be wrapped.
|
Wrap a functor to transfer context.
| 396 | 434 |
def fork_task_context(functor, context=None):
'''Wrap a functor to transfer context.
Usage example:
gevent.spawn(zerorpc.fork_task_context(myfunction), args...)
The goal is to permit context "inheritance" from a task to another.
Consider the following example:
zerorpc.Server receive a new event
- task1 is created to handle this event this task will be linked
to the initial event context. zerorpc.Server does that for you.
- task1 make use of some zerorpc.Client instances, the initial
event context is transfered on every call.
- task1 spawn a new task2.
- task2 make use of some zerorpc.Client instances, it's a fresh
context. Thus there is no link to the initial context that
spawned task1.
- task1 spawn a new fork_task_context(task3).
- task3 make use of some zerorpc.Client instances, the initial
event context is transfered on every call.
A real use case is a distributed tracer. Each time a new event is
created, a trace_id is injected in it or copied from the current task
context. This permit passing the trace_id from a zerorpc.Server to
another via zerorpc.Client.
The simple rule to know if a task need to be wrapped is:
- if the new task will make any zerorpc call, it should be wrapped.
'''
context = context or Context.get_instance()
xheader = context.hook_get_task_context()
def wrapped(*args, **kargs):
context.hook_load_task_context(xheader)
return functor(*args, **kargs)
return wrapped
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/core.py#L396-L434
| 36 |
[
0,
32,
33,
34,
35,
36,
37,
38
] | 20.512821 |
[] | 0 | false | 85.657371 | 39 | 3 | 100 | 30 |
def fork_task_context(functor, context=None):
'''Wrap a functor to transfer context.
Usage example:
gevent.spawn(zerorpc.fork_task_context(myfunction), args...)
The goal is to permit context "inheritance" from a task to another.
Consider the following example:
zerorpc.Server receive a new event
- task1 is created to handle this event this task will be linked
to the initial event context. zerorpc.Server does that for you.
- task1 make use of some zerorpc.Client instances, the initial
event context is transfered on every call.
- task1 spawn a new task2.
- task2 make use of some zerorpc.Client instances, it's a fresh
context. Thus there is no link to the initial context that
spawned task1.
- task1 spawn a new fork_task_context(task3).
- task3 make use of some zerorpc.Client instances, the initial
event context is transfered on every call.
A real use case is a distributed tracer. Each time a new event is
created, a trace_id is injected in it or copied from the current task
context. This permit passing the trace_id from a zerorpc.Server to
another via zerorpc.Client.
The simple rule to know if a task need to be wrapped is:
- if the new task will make any zerorpc call, it should be wrapped.
'''
context = context or Context.get_instance()
xheader = context.hook_get_task_context()
def wrapped(*args, **kargs):
context.hook_load_task_context(xheader)
return functor(*args, **kargs)
return wrapped
| 22,603 |
0rpc/zerorpc-python
|
99ee6e47c8baf909b97eec94f184a19405f392a2
|
zerorpc/core.py
|
ServerBase.__init__
|
(self, channel, methods=None, name=None, context=None,
pool_size=None, heartbeat=5)
| 54 | 72 |
def __init__(self, channel, methods=None, name=None, context=None,
pool_size=None, heartbeat=5):
self._multiplexer = ChannelMultiplexer(channel)
if methods is None:
methods = self
self._context = context or Context.get_instance()
self._name = name or self._extract_name()
self._task_pool = gevent.pool.Pool(size=pool_size)
self._acceptor_task = None
self._methods = self._filter_methods(ServerBase, self, methods)
self._inject_builtins()
self._heartbeat_freq = heartbeat
for (k, functor) in iteritems(self._methods):
if not isinstance(functor, DecoratorBase):
self._methods[k] = rep(functor)
|
https://github.com/0rpc/zerorpc-python/blob/99ee6e47c8baf909b97eec94f184a19405f392a2/project36/zerorpc/core.py#L54-L72
| 36 |
[
0,
2,
3,
4,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 89.473684 |
[
5
] | 5.263158 | false | 85.657371 | 19 | 6 | 94.736842 | 0 |
def __init__(self, channel, methods=None, name=None, context=None,
pool_size=None, heartbeat=5):
self._multiplexer = ChannelMultiplexer(channel)
if methods is None:
methods = self
self._context = context or Context.get_instance()
self._name = name or self._extract_name()
self._task_pool = gevent.pool.Pool(size=pool_size)
self._acceptor_task = None
self._methods = self._filter_methods(ServerBase, self, methods)
self._inject_builtins()
self._heartbeat_freq = heartbeat
for (k, functor) in iteritems(self._methods):
if not isinstance(functor, DecoratorBase):
self._methods[k] = rep(functor)
| 22,604 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.