diff --git a/README.md b/README.md index 034b5ff..8e62bfe 100644 --- a/README.md +++ b/README.md @@ -321,3 +321,5 @@ for await (const file of files) { * On the bridge to call JavaScript from Python, due to the limiatations of Python and cross-platform IPC, we currently communicate over standard error which means that JSON output in JS standard error can interfere with the bridge. The same issue exists on Windows with python. You are however very unlikely to have issues with this. * You can set the Node.js/Python binary paths by setting the `NODE_BIN` or `PYTHON_BIN` enviornment variables before importing the library. Otherwise, the `node` and `python3` or `python` binaries will be called relative to your PATH enviornment variable. + +* Function calls will timeout after 100000 ms and throw a `BridgeException` error. That default value can be overridden by defining the new value of `REQ_TIMEOUT` in an environment variable. \ No newline at end of file diff --git a/src/javascript/js/pyi.js b/src/javascript/js/pyi.js index 32f5bdd..0206c37 100644 --- a/src/javascript/js/pyi.js +++ b/src/javascript/js/pyi.js @@ -6,7 +6,8 @@ const util = require('util') if (typeof performance === 'undefined') var { performance } = require('perf_hooks') const log = () => { } const errors = require('./errors') -const REQ_TIMEOUT = 100000 +// use REQ_TIMEOUT env var value if parseable as integer, otherwise default to 100000 (ms) +const REQ_TIMEOUT = parseInt(process.env.REQ_TIMEOUT) || 100000 class BridgeException extends Error { constructor (...a) { diff --git a/src/pythonia/Bridge.js b/src/pythonia/Bridge.js index 6989302..c30294d 100644 --- a/src/pythonia/Bridge.js +++ b/src/pythonia/Bridge.js @@ -3,7 +3,8 @@ const { JSBridge } = require('./jsi') const errors = require('./errors') const log = process.env.DEBUG ? console.debug : () => {} // const log = console.log -const REQ_TIMEOUT = 100000 +// use REQ_TIMEOUT env var value if parseable as integer, otherwise default to 100000 (ms) +const REQ_TIMEOUT = parseInt(process.env.REQ_TIMEOUT) || 100000 class BridgeException extends Error { constructor (...a) {