1 # Copyright 2019 gRPC authors.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 cdef class _AsyncioSocket:
19 grpc_custom_socket * _grpc_socket
20 grpc_custom_read_callback _grpc_read_cb
21 grpc_custom_write_callback _grpc_write_cb
29 # Caches the picked event loop, so we can avoid the 30ns overhead each
30 # time we need access to the event loop.
32 # TODO(lidiz) Drop after 3.6 deprecation. Python 3.7 introduces methods
33 # like `is_closing()` to help graceful shutdown.
36 # Client-side attributes
37 grpc_custom_connect_callback _grpc_connect_cb
39 # Server-side attributes
40 grpc_custom_accept_callback _grpc_accept_cb
41 grpc_custom_socket * _grpc_client_socket
47 cdef _AsyncioSocket create(
48 grpc_custom_socket * grpc_socket,
52 cdef _AsyncioSocket create_with_py_socket(grpc_custom_socket * grpc_socket, object py_socket)
54 cdef void connect(self, object host, object port, grpc_custom_connect_callback grpc_connect_cb)
55 cdef void write(self, grpc_slice_buffer * g_slice_buffer, grpc_custom_write_callback grpc_write_cb)
56 cdef void read(self, char * buffer_, size_t length, grpc_custom_read_callback grpc_read_cb)
57 cdef bint is_connected(self)
60 cdef accept(self, grpc_custom_socket* grpc_socket_client, grpc_custom_accept_callback grpc_accept_cb)
62 cdef tuple peername(self)
63 cdef tuple sockname(self)