Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to configure call timeout (REQ_TIMEOUT) from env var #90

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion src/javascript/js/pyi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/pythonia/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading