From 561e7b6738367b3797709eb98e64fb0f921511eb Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Sat, 13 Apr 2024 17:57:56 +0800 Subject: [PATCH] feat: support JupyterLite/Emscripten This is a fix on Thrift python, to enable nebula-python being supported on jupyterlite, a wasm env in browser powered by pyodide. This will enable embed runnable jupyter/python client of nebulagraph in browser or inline of docs/toturials in the future. --- nebula3/fbthrift/transport/TSocket.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nebula3/fbthrift/transport/TSocket.py b/nebula3/fbthrift/transport/TSocket.py index 3ec3b9c7..a413027f 100644 --- a/nebula3/fbthrift/transport/TSocket.py +++ b/nebula3/fbthrift/transport/TSocket.py @@ -201,6 +201,11 @@ def _setHandleCloseOnExec(self, handle): if fcntl is None: return + # pyodide doesn't support fcntl, so we need to skip in this case, too. + # ref: https://github.com/pyodide/pyodide/discussions/4150 + if sys.platform == 'emscripten': + return + flags = fcntl.fcntl(handle, fcntl.F_GETFD, 0) if flags < 0: raise IOError('Error in retrieving file options')