Index: third_party/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx |
diff --git a/third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/echo_wsh.py b/third_party/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx |
similarity index 56% |
copy from third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/echo_wsh.py |
copy to third_party/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx |
index 429f58186e3fce43dc21e81e0f9d7e20c7e0bf70..30cc7a132b01cfecbe47c1d42d47f22bd1b18a57 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/websocket/workers/resources/echo_wsh.py |
+++ b/third_party/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx |
@@ -1,4 +1,4 @@ |
-# Copyright 2010, Google Inc. |
+# Copyright 2015-2016, Google Inc. |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -27,20 +27,44 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+cimport cpython |
-from mod_pywebsocket import msgutil |
+import pkg_resources |
+import os.path |
+import sys |
+# TODO(atash): figure out why the coverage tool gets confused about the Cython |
+# coverage plugin when the following files don't have a '.pxi' suffix. |
+include "grpc/_cython/_cygrpc/call.pyx.pxi" |
+include "grpc/_cython/_cygrpc/channel.pyx.pxi" |
+include "grpc/_cython/_cygrpc/credentials.pyx.pxi" |
+include "grpc/_cython/_cygrpc/completion_queue.pyx.pxi" |
+include "grpc/_cython/_cygrpc/records.pyx.pxi" |
+include "grpc/_cython/_cygrpc/security.pyx.pxi" |
+include "grpc/_cython/_cygrpc/server.pyx.pxi" |
-_GOODBYE_MESSAGE = 'Goodbye' |
+# |
+# Global state |
+# |
+ |
+cdef class _ModuleState: |
+ |
+ cdef bint is_loaded |
+ def __cinit__(self): |
+ if 'win32' in sys.platform: |
+ filename = pkg_resources.resource_filename( |
+ 'grpc._cython', '_windows/grpc_c.64.python') |
+ if not pygrpc_load_core(filename): |
+ raise ImportError('failed to load core gRPC library') |
+ grpc_init() |
+ self.is_loaded = True |
+ grpc_set_ssl_roots_override_callback( |
+ <grpc_ssl_roots_override_callback>ssl_roots_override_callback) |
-def web_socket_do_extra_handshake(request): |
- pass # Always accept. |
+ def __dealloc__(self): |
+ if self.is_loaded: |
+ grpc_shutdown() |
+_module_state = _ModuleState() |
-def web_socket_transfer_data(request): |
- while True: |
- line = msgutil.receive_message(request) |
- msgutil.send_message(request, line) |
- if line == _GOODBYE_MESSAGE: |
- return |