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
vllm_cscc
Commits
8ebf271b
Unverified
Commit
8ebf271b
authored
Jan 22, 2026
by
Isotr0py
Committed by
GitHub
Jan 22, 2026
Browse files
[Misc] Replace urllib's `urlparse` with urllib3's `parse_url` (#32746)
Signed-off-by:
Isotr0py
<
mozf@mail2.sysu.edu.cn
>
parent
49a12622
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
16 deletions
+23
-16
vllm/connections.py
vllm/connections.py
+2
-2
vllm/envs.py
vllm/envs.py
+2
-2
vllm/multimodal/utils.py
vllm/multimodal/utils.py
+15
-10
vllm/utils/network_utils.py
vllm/utils/network_utils.py
+4
-2
No files found.
vllm/connections.py
View file @
8ebf271b
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
from
collections.abc
import
Mapping
,
MutableMapping
from
collections.abc
import
Mapping
,
MutableMapping
from
pathlib
import
Path
from
pathlib
import
Path
from
urllib.parse
import
urlparse
import
aiohttp
import
aiohttp
import
requests
import
requests
from
urllib3.util
import
parse_url
from
vllm.version
import
__version__
as
VLLM_VERSION
from
vllm.version
import
__version__
as
VLLM_VERSION
...
@@ -37,7 +37,7 @@ class HTTPConnection:
...
@@ -37,7 +37,7 @@ class HTTPConnection:
return
self
.
_async_client
return
self
.
_async_client
def
_validate_http_url
(
self
,
url
:
str
):
def
_validate_http_url
(
self
,
url
:
str
):
parsed_url
=
url
parse
(
url
)
parsed_url
=
parse
_url
(
url
)
if
parsed_url
.
scheme
not
in
(
"http"
,
"https"
):
if
parsed_url
.
scheme
not
in
(
"http"
,
"https"
):
raise
ValueError
(
raise
ValueError
(
...
...
vllm/envs.py
View file @
8ebf271b
...
@@ -439,9 +439,9 @@ def get_vllm_port() -> int | None:
...
@@ -439,9 +439,9 @@ def get_vllm_port() -> int | None:
try
:
try
:
return
int
(
port
)
return
int
(
port
)
except
ValueError
as
err
:
except
ValueError
as
err
:
from
urllib
.parse
import
url
parse
from
urllib
3.util
import
parse
_url
parsed
=
url
parse
(
port
)
parsed
=
parse
_url
(
port
)
if
parsed
.
scheme
:
if
parsed
.
scheme
:
raise
ValueError
(
raise
ValueError
(
f
"VLLM_PORT '
{
port
}
' appears to be a URI. "
f
"VLLM_PORT '
{
port
}
' appears to be a URI. "
...
...
vllm/multimodal/utils.py
View file @
8ebf271b
...
@@ -9,13 +9,13 @@ from concurrent.futures import ThreadPoolExecutor
...
@@ -9,13 +9,13 @@ from concurrent.futures import ThreadPoolExecutor
from
itertools
import
groupby
from
itertools
import
groupby
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
,
Any
,
TypeVar
from
typing
import
TYPE_CHECKING
,
Any
,
TypeVar
from
urllib.parse
import
ParseResult
,
urlparse
from
urllib.request
import
url2pathname
from
urllib.request
import
url2pathname
import
numpy
as
np
import
numpy
as
np
import
numpy.typing
as
npt
import
numpy.typing
as
npt
import
torch
import
torch
from
PIL
import
Image
,
UnidentifiedImageError
from
PIL
import
Image
,
UnidentifiedImageError
from
urllib3.util
import
Url
,
parse_url
import
vllm.envs
as
envs
import
vllm.envs
as
envs
from
vllm.connections
import
HTTPConnection
,
global_http_connection
from
vllm.connections
import
HTTPConnection
,
global_http_connection
...
@@ -105,11 +105,14 @@ class MediaConnector:
...
@@ -105,11 +105,14 @@ class MediaConnector:
def
_load_data_url
(
def
_load_data_url
(
self
,
self
,
url_spec
:
ParseResult
,
url_spec
:
Url
,
media_io
:
MediaIO
[
_M
],
media_io
:
MediaIO
[
_M
],
)
->
_M
:
# type: ignore[type-var]
)
->
_M
:
# type: ignore[type-var]
data_spec
,
data
=
url_spec
.
path
.
split
(
","
,
1
)
url_spec_path
=
url_spec
.
path
or
""
data_spec
,
data
=
url_spec_path
.
split
(
","
,
1
)
media_type
,
data_type
=
data_spec
.
split
(
";"
,
1
)
media_type
,
data_type
=
data_spec
.
split
(
";"
,
1
)
# media_type starts with a leading "/" (e.g., "/video/jpeg")
media_type
=
media_type
.
lstrip
(
"/"
)
if
data_type
!=
"base64"
:
if
data_type
!=
"base64"
:
msg
=
"Only base64 data URLs are supported for now."
msg
=
"Only base64 data URLs are supported for now."
...
@@ -119,7 +122,7 @@ class MediaConnector:
...
@@ -119,7 +122,7 @@ class MediaConnector:
def
_load_file_url
(
def
_load_file_url
(
self
,
self
,
url_spec
:
ParseResult
,
url_spec
:
Url
,
media_io
:
MediaIO
[
_M
],
media_io
:
MediaIO
[
_M
],
)
->
_M
:
# type: ignore[type-var]
)
->
_M
:
# type: ignore[type-var]
allowed_local_media_path
=
self
.
allowed_local_media_path
allowed_local_media_path
=
self
.
allowed_local_media_path
...
@@ -128,7 +131,9 @@ class MediaConnector:
...
@@ -128,7 +131,9 @@ class MediaConnector:
"Cannot load local files without `--allowed-local-media-path`."
"Cannot load local files without `--allowed-local-media-path`."
)
)
filepath
=
Path
(
url2pathname
(
url_spec
.
netloc
+
url_spec
.
path
))
url_spec_path
=
url_spec
.
path
or
""
url_spec_netloc
=
url_spec
.
netloc
or
""
filepath
=
Path
(
url2pathname
(
url_spec_netloc
+
url_spec_path
))
if
allowed_local_media_path
not
in
filepath
.
resolve
().
parents
:
if
allowed_local_media_path
not
in
filepath
.
resolve
().
parents
:
raise
ValueError
(
raise
ValueError
(
f
"The file path
{
filepath
}
must be a subpath "
f
"The file path
{
filepath
}
must be a subpath "
...
@@ -137,7 +142,7 @@ class MediaConnector:
...
@@ -137,7 +142,7 @@ class MediaConnector:
return
media_io
.
load_file
(
filepath
)
return
media_io
.
load_file
(
filepath
)
def
_assert_url_in_allowed_media_domains
(
self
,
url_spec
:
ParseResult
)
->
None
:
def
_assert_url_in_allowed_media_domains
(
self
,
url_spec
:
Url
)
->
None
:
if
(
if
(
self
.
allowed_media_domains
self
.
allowed_media_domains
and
url_spec
.
hostname
not
in
self
.
allowed_media_domains
and
url_spec
.
hostname
not
in
self
.
allowed_media_domains
...
@@ -155,9 +160,9 @@ class MediaConnector:
...
@@ -155,9 +160,9 @@ class MediaConnector:
*
,
*
,
fetch_timeout
:
int
|
None
=
None
,
fetch_timeout
:
int
|
None
=
None
,
)
->
_M
:
# type: ignore[type-var]
)
->
_M
:
# type: ignore[type-var]
url_spec
=
url
parse
(
url
)
url_spec
=
parse
_url
(
url
)
if
url_spec
.
scheme
.
startswith
(
"http"
):
if
url_spec
.
scheme
and
url_spec
.
scheme
.
startswith
(
"http"
):
self
.
_assert_url_in_allowed_media_domains
(
url_spec
)
self
.
_assert_url_in_allowed_media_domains
(
url_spec
)
connection
=
self
.
connection
connection
=
self
.
connection
...
@@ -185,10 +190,10 @@ class MediaConnector:
...
@@ -185,10 +190,10 @@ class MediaConnector:
*
,
*
,
fetch_timeout
:
int
|
None
=
None
,
fetch_timeout
:
int
|
None
=
None
,
)
->
_M
:
)
->
_M
:
url_spec
=
url
parse
(
url
)
url_spec
=
parse
_url
(
url
)
loop
=
asyncio
.
get_running_loop
()
loop
=
asyncio
.
get_running_loop
()
if
url_spec
.
scheme
.
startswith
(
"http"
):
if
url_spec
.
scheme
and
url_spec
.
scheme
.
startswith
(
"http"
):
self
.
_assert_url_in_allowed_media_domains
(
url_spec
)
self
.
_assert_url_in_allowed_media_domains
(
url_spec
)
connection
=
self
.
connection
connection
=
self
.
connection
...
...
vllm/utils/network_utils.py
View file @
8ebf271b
...
@@ -11,12 +11,12 @@ from collections.abc import (
...
@@ -11,12 +11,12 @@ from collections.abc import (
Sequence
,
Sequence
,
)
)
from
typing
import
Any
from
typing
import
Any
from
urllib.parse
import
urlparse
from
uuid
import
uuid4
from
uuid
import
uuid4
import
psutil
import
psutil
import
zmq
import
zmq
import
zmq.asyncio
import
zmq.asyncio
from
urllib3.util
import
parse_url
import
vllm.envs
as
envs
import
vllm.envs
as
envs
from
vllm.logger
import
init_logger
from
vllm.logger
import
init_logger
...
@@ -217,13 +217,15 @@ def find_process_using_port(port: int) -> psutil.Process | None:
...
@@ -217,13 +217,15 @@ def find_process_using_port(port: int) -> psutil.Process | None:
def
split_zmq_path
(
path
:
str
)
->
tuple
[
str
,
str
,
str
]:
def
split_zmq_path
(
path
:
str
)
->
tuple
[
str
,
str
,
str
]:
"""Split a zmq path into its parts."""
"""Split a zmq path into its parts."""
parsed
=
url
parse
(
path
)
parsed
=
parse
_url
(
path
)
if
not
parsed
.
scheme
:
if
not
parsed
.
scheme
:
raise
ValueError
(
f
"Invalid zmq path:
{
path
}
"
)
raise
ValueError
(
f
"Invalid zmq path:
{
path
}
"
)
scheme
=
parsed
.
scheme
scheme
=
parsed
.
scheme
host
=
parsed
.
hostname
or
""
host
=
parsed
.
hostname
or
""
port
=
str
(
parsed
.
port
or
""
)
port
=
str
(
parsed
.
port
or
""
)
if
host
.
startswith
(
"["
)
and
host
.
endswith
(
"]"
):
host
=
host
[
1
:
-
1
]
# Remove brackets for IPv6 address
if
scheme
==
"tcp"
and
not
all
((
host
,
port
)):
if
scheme
==
"tcp"
and
not
all
((
host
,
port
)):
# The host and port fields are required for tcp
# The host and port fields are required for tcp
...
...
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