Skip to content

Commit

Permalink
0.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 4, 2024
1 parent 8ddbe52 commit f3c19b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "viser"
version = "0.2.11"
version = "0.2.12"
description = "3D visualization + Python"
readme = "README.md"
license = { text="MIT" }
Expand Down
1 change: 1 addition & 0 deletions src/viser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ._scene_handles import HemisphereLightHandle as HemisphereLightHandle
from ._scene_handles import ImageHandle as ImageHandle
from ._scene_handles import LabelHandle as LabelHandle
from ._scene_handles import LineSegmentsHandle as LineSegmentsHandle
from ._scene_handles import MeshHandle as MeshHandle
from ._scene_handles import MeshSkinnedBoneHandle as MeshSkinnedBoneHandle
from ._scene_handles import MeshSkinnedHandle as MeshSkinnedHandle
Expand Down
27 changes: 16 additions & 11 deletions src/viser/infra/_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,6 @@ async def ws_handler(
connection: websockets.asyncio.server.ServerConnection,
) -> None:
"""Handler for websocket connections."""

# <Hack>
# Suppress errors for: https://github.com/python-websockets/websockets/issues/1513
# TODO: remove this when websockets behavior changes upstream.
class NoHttpErrors(logging.Filter):
def filter(self, record):
return not record.getMessage() == "opening handshake failed"

connection.logger.logger.addFilter(NoHttpErrors()) # type: ignore
# </Hack>

async with count_lock:
nonlocal connection_count
client_id = ClientId(connection_count)
Expand Down Expand Up @@ -414,10 +403,26 @@ def handle_incoming(message: Message) -> None:
file_cache: dict[Path, bytes] = {}
file_cache_gzipped: dict[Path, bytes] = {}

filter_added = False

def viser_http_server(
connection: ServerConnection,
request: Request,
) -> Response | None:
# <Hack>
# Suppress errors for: https://github.com/python-websockets/websockets/issues/1513
# TODO: remove this when websockets behavior changes upstream.
nonlocal filter_added
if not filter_added:

class NoHttpErrors(logging.Filter):
def filter(self, record):
return not record.getMessage() == "opening handshake failed"

connection.logger.logger.addFilter(NoHttpErrors()) # type: ignore
filter_added = True
# </Hack>

# Ignore websocket packets.
if request.headers.get("Upgrade") == "websocket":
return None
Expand Down

0 comments on commit f3c19b3

Please sign in to comment.