Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
427ca9ab
Unverified
Commit
427ca9ab
authored
Nov 04, 2025
by
Yan Ru Pei
Committed by
GitHub
Nov 05, 2025
Browse files
chore: no need for explicit Python::with_gil (#4075)
Signed-off-by:
PeaBrane
<
yanrpei@gmail.com
>
parent
17af7a0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
48 deletions
+33
-48
lib/bindings/python/rust/llm/kv.rs
lib/bindings/python/rust/llm/kv.rs
+33
-48
No files found.
lib/bindings/python/rust/llm/kv.rs
View file @
427ca9ab
...
...
@@ -1115,8 +1115,6 @@ impl KvPushRouter {
extra_args
:
Option
<
PyObject
>
,
)
->
PyResult
<
Bound
<
'p
,
PyAny
>>
{
// Depythonize the options with defaults
let
(
stop_conditions
,
sampling_options
,
output_options
,
router_config_override
,
extra_args
)
=
Python
::
with_gil
(|
py
|
{
let
stop_conditions
:
StopConditions
=
if
let
Some
(
obj
)
=
stop_conditions
{
depythonize
(
obj
.bind
(
py
))
.map_err
(
to_pyerr
)
?
}
else
{
...
...
@@ -1148,15 +1146,6 @@ impl KvPushRouter {
None
};
Ok
::
<
_
,
PyErr
>
((
stop_conditions
,
sampling_options
,
output_options
,
router_config_override
,
extra_args
,
))
})
?
;
// Build the PreprocessedRequest
let
mut
request_builder
=
llm_rs
::
protocols
::
common
::
preprocessor
::
PreprocessedRequest
::
builder
();
...
...
@@ -1188,7 +1177,7 @@ impl KvPushRouter {
)
->
PyResult
<
Bound
<
'p
,
PyAny
>>
{
// Depythonize the request directly into PreprocessedRequest
let
request
:
llm_rs
::
protocols
::
common
::
preprocessor
::
PreprocessedRequest
=
Python
::
with_gil
(|
py
|
depythonize
(
request
.bind
(
py
))
.map_err
(
to_pyerr
)
)
?
;
depythonize
(
request
.bind
(
py
))
.map_err
(
to_pyerr
)
?
;
// Use the helper method to process the request
Self
::
process_request_to_stream
(
py
,
self
.inner
.clone
(),
request
)
...
...
@@ -1203,11 +1192,9 @@ impl KvPushRouter {
request_id
:
Option
<
String
>
,
)
->
PyResult
<
Bound
<
'p
,
PyAny
>>
{
let
router_config_override
=
if
let
Some
(
obj
)
=
router_config_override
{
Python
::
with_gil
(|
py
|
{
let
override_config
:
llm_rs
::
kv_router
::
RouterConfigOverride
=
depythonize
(
obj
.bind
(
py
))
.map_err
(
to_pyerr
)
?
;
Ok
::
<
_
,
PyErr
>
(
Some
(
override_config
))
})
?
Some
(
override_config
)
}
else
{
None
};
...
...
@@ -1250,11 +1237,9 @@ impl KvPushRouter {
)
?
;
let
router_config_override
=
if
let
Some
(
obj
)
=
router_config_override
{
Python
::
with_gil
(|
py
|
{
let
override_config
:
llm_rs
::
kv_router
::
RouterConfigOverride
=
depythonize
(
obj
.bind
(
py
))
.map_err
(
to_pyerr
)
?
;
Ok
::
<
_
,
PyErr
>
(
Some
(
override_config
))
})
?
Some
(
override_config
)
}
else
{
None
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment