Skip to content

Commit 5b19cc2

Browse files
authored
Avoid yielding messages on GeneratorExit in sync server (#90)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
1 parent d23fe18 commit 5b19cc2

4 files changed

Lines changed: 596 additions & 448 deletions

File tree

conformance/test/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,10 @@ async def serve_gunicorn(
538538
args = [
539539
"--bind=127.0.0.1:0",
540540
"--workers=4",
541-
"--worker-class=gevent",
541+
"--worker-class=gthread",
542+
"--threads=16",
542543
"--reuse-port",
544+
"--keep-alive=0",
543545
]
544546
if certfile:
545547
args.append(f"--certfile={certfile}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dev = [
4444
"hypercorn==0.17.3",
4545
"granian==2.5.7",
4646
"grpcio-tools==1.76.0",
47-
"gunicorn[gevent]==23.0.0",
47+
"gunicorn==23.0.0",
4848
"just-bin==1.42.4; sys_platform != 'win32'",
4949
"pyright[nodejs]==1.1.405",
5050
"pyvoy==0.2.0",

src/connectrpc/_server_sync.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,14 @@ def _response_stream(
574574
yield body
575575
except Exception as e:
576576
error = e
577-
finally:
578-
yield _end_response(
579-
writer.end(
580-
ctx.response_trailers(),
581-
ConnectWireError.from_exception(error) if error else None,
582-
),
583-
send_trailers,
584-
)
577+
578+
yield _end_response(
579+
writer.end(
580+
ctx.response_trailers(),
581+
ConnectWireError.from_exception(error) if error else None,
582+
),
583+
send_trailers,
584+
)
585585

586586

587587
def _consume_single_request(stream: Iterator[_REQ]) -> _REQ:

0 commit comments

Comments
 (0)