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 path web app run #6842

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGES/6839.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web.run_app(path=) accept pathlib.Path
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Robert Lu
Robert Nikolich
Roman Markeloff
Roman Podoliaka
Samir Akarioh
Samuel Colvin
Sean Hunt
Sebastian Acuna
Expand Down
7 changes: 4 additions & 3 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import logging
import pathlib
SamirPS marked this conversation as resolved.
Show resolved Hide resolved
import socket
import sys
from argparse import ArgumentParser
Expand Down Expand Up @@ -290,7 +291,7 @@ async def _run_app(
*,
host: Optional[Union[str, HostSequence]] = None,
port: Optional[int] = None,
path: Optional[str] = None,
path: Optional[Union[str, pathlib.Path]] = None,
sock: Optional[Union[socket.socket, TypingIterable[socket.socket]]] = None,
shutdown_timeout: float = 60.0,
keepalive_timeout: float = 75.0,
Expand Down Expand Up @@ -366,7 +367,7 @@ async def _run_app(
)

if path is not None:
if isinstance(path, (str, bytes, bytearray, memoryview)):
if isinstance(path, (str, bytes, bytearray, memoryview, pathlib.Path)):
sites.append(
UnixSite(
runner,
Expand Down Expand Up @@ -464,7 +465,7 @@ def run_app(
debug: bool = False,
host: Optional[Union[str, HostSequence]] = None,
port: Optional[int] = None,
path: Optional[str] = None,
path: Optional[Union[str, pathlib.Path]] = None,
sock: Optional[Union[socket.socket, TypingIterable[socket.socket]]] = None,
shutdown_timeout: float = 60.0,
keepalive_timeout: float = 75.0,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def test_run_app_custom_backlog_unix(patched_loop: Any) -> None:
def test_run_app_http_unix_socket(patched_loop: Any, tmp_path: Any) -> None:
app = web.Application()

sock_path = str(tmp_path / "socket.sock")
sock_path = tmp_path / "socket.sock"
printer = mock.Mock(wraps=stopper(patched_loop))
web.run_app(app, path=sock_path, print=printer, loop=patched_loop)

Expand All @@ -532,7 +532,7 @@ def test_run_app_http_unix_socket(patched_loop: Any, tmp_path: Any) -> None:
def test_run_app_https_unix_socket(patched_loop: Any, tmp_path: Any) -> None:
app = web.Application()

sock_path = str(tmp_path / "socket.sock")
sock_path = tmp_path / "socket.sock"
ssl_context = ssl.create_default_context()
printer = mock.Mock(wraps=stopper(patched_loop))
web.run_app(
Expand Down