Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Oct 28, 2022
2 parents 43f5752 + ff3cf93 commit b1fcb0c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']

services:
postgres:
Expand Down
2 changes: 1 addition & 1 deletion emmett/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.4.10"
__version__ = "2.4.11"
3 changes: 0 additions & 3 deletions emmett/asgi/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from uvicorn.config import Config as UvicornConfig
from uvicorn.lifespan.on import LifespanOn
from uvicorn.middleware.debug import DebugMiddleware
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware


Expand Down Expand Up @@ -114,8 +113,6 @@ def load(self):
self.loaded_app = self.app
self.interface = "asgi3"

if self.debug:
self.loaded_app = DebugMiddleware(self.loaded_app)
if self.proxy_headers:
self.loaded_app = ProxyHeadersMiddleware(
self.loaded_app, trusted_hosts=self.forwarded_allow_ips
Expand Down
4 changes: 2 additions & 2 deletions emmett/asgi/protocols/http/h11.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def handle_events(self):
while True:
try:
event = self.conn.next_event()
except h11.RemoteProtocolError as exc:
except h11.RemoteProtocolError:
msg = "Invalid HTTP request received."
self.logger.warning(msg, exc_info=exc)
self.logger.warning(msg)
self.send_400_response(msg)
return
event_type = type(event)
Expand Down
16 changes: 15 additions & 1 deletion emmett/asgi/protocols/http/httptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"""

from uvicorn.protocols.http.httptools_impl import (
HttpToolsProtocol as _HttpToolsProtocol
HttpToolsProtocol as _HttpToolsProtocol,
httptools
)

from . import protocols
Expand All @@ -20,6 +21,19 @@
class HTTPToolsProtocol(_HttpToolsProtocol):
alpn_protocols = ["http/1.1"]

def data_received(self, data: bytes) -> None:
self._unset_keepalive_if_required()

try:
self.parser.feed_data(data)
except httptools.HttpParserError:
msg = "Invalid HTTP request received."
self.logger.warning(msg)
self.send_400_response(msg)
return
except httptools.HttpParserUpgrade:
self.handle_upgrade()

def handle_upgrade(self):
upgrade_value = None
for name, value in self.headers:
Expand Down
4 changes: 4 additions & 0 deletions emmett/asgi/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def init_signals(self):
for s in self.SIGNALS:
signal.signal(s, signal.SIG_DFL)

signal.signal(signal.SIGUSR1, self.handle_usr1)
# Don't let SIGUSR1 disturb active requests by interrupting system calls
signal.siginterrupt(signal.SIGUSR1, False)

def run(self):
self.config.app = self.wsgi
self.config.app.send_signal(Signals.after_loop, loop=self.config.loop)
Expand Down
2 changes: 2 additions & 0 deletions emmett/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@


class Signals(str, Enum):
__str__ = lambda v: v.value

after_database = "after_database"
after_loop = "after_loop"
after_route = "after_route"
Expand Down
1 change: 1 addition & 0 deletions emmett/orm/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

from collections import OrderedDict
from enum import Enum
from typing import List

from .errors import MissingFieldsForCompute
Expand Down
2 changes: 2 additions & 0 deletions emmett/orm/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,8 @@ def __init__(self, *args, **kwargs):


class TransactionOps(str, Enum):
__str__ = lambda v: v.value

insert = "insert"
update = "update"
delete = "delete"
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Emmett"
version = "2.4.10"
version = "2.4.11"
description = "The web framework for inventors"
authors = ["Giovanni Barillari <[email protected]>"]
license = "BSD-3-Clause"
Expand Down Expand Up @@ -52,13 +52,13 @@ python-rapidjson = "^1.0"
pyyaml = "^5.4"
renoir = "^1.5"
severus = "^1.1"
uvicorn = "~0.17.6"
uvicorn = "~0.19.0"
websockets = "^10.0"

httptools = { version = "~0.4.0", markers = "sys_platform != 'win32'" }
uvloop = { version = "~0.16.0", markers = "sys_platform != 'win32'" }
httptools = { version = "~0.5.0", markers = "sys_platform != 'win32'" }
uvloop = { version = "~0.17.0", markers = "sys_platform != 'win32'" }

orjson = { version = "~3.6.5", optional = true }
orjson = { version = "~3.8", optional = true }
emmett-crypto = { version = "^0.2.0", optional = true }

[tool.poetry.dev-dependencies]
Expand Down

0 comments on commit b1fcb0c

Please sign in to comment.