You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,24 @@ the `Math.sin` in Ruby:
61
61
Type conversions from Ruby to Python are automatically performed for numeric,
62
62
boolean, string, arrays, and hashes.
63
63
64
+
### Releasing the RubyVM GVL during Python function calls
65
+
66
+
You may want to release the RubyVM GVL when you call a Python function that takes very long runtime.
67
+
PyCall provides `PyCall.without_gvl` method for such purpose. When PyCall performs python function call,
68
+
PyCall checks the current context, and then it releases the RubyVM GVL when the current context is in a `PyCall.without_gvl`'s block.
69
+
70
+
```ruby
71
+
PyCall.without_gvl do
72
+
# In this block, all Python function calls are performed without
73
+
# the GVL acquisition.
74
+
pyobj.long_running_function()
75
+
end
76
+
77
+
# Outside of PyCall.without_gvl block,
78
+
# all Python function calls are performed with the GVL acquisition.
79
+
pyobj.long_running_function()
80
+
```
81
+
64
82
### Debugging python finder
65
83
66
84
When you encounter `PyCall::PythonNotFound` error, you can investigate PyCall's python finder by setting `PYCALL_DEBUG_FIND_LIBPYTHON` environment variable to `1`. You can see the log like below:
0 commit comments