-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Version
1.41.1
Steps to reproduce
Environment
- Python Version: 3.9.18
- Playwright Browser : Chromium
Python Dependencies
- Quart Version : 0.19.4
- Hypercorn Version : 0.16.0
Code
import signal
import logging
import asyncio
from quart import Quart
from playwright.async_api import async_playwright
from hypercorn.asyncio import serve
from hypercorn import Config
# logging.disable(logging.CRITICAL)
app = Quart(__name__)
@app.route("/")
async def index():
return "<hml>Hello world</html>"
shutdown_event = asyncio.Event()
async def test(loop):
print("Test")
async with async_playwright() as p:
print("Start")
browser = await p.chromium.launch()
context = await browser.new_context(device_scale_factor=1)
page = await context.new_page()
print("Page created")
await page.goto("http://localhost:5000")
print("Goto page")
await page.screenshot(path="hello.png", type='png')
print("Finished")
shutdown_event.set()
config = Config()
config.bind = ["localhost:5000"]
def save():
loop = asyncio.get_event_loop()
loop.create_task(test(loop))
loop.run_until_complete(
serve(app, config, shutdown_trigger=shutdown_event.wait)
)
print("End")
save()
save()
Expected behavior
If I don't duplicate the task, I don't have any error:
import signal
import logging
import asyncio
from quart import Quart
from playwright.async_api import async_playwright
from hypercorn.asyncio import serve
from hypercorn import Config
# logging.disable(logging.CRITICAL)
def make_message(message):
app = Quart(__name__)
@app.route("/")
async def index():
return f"<hml>{message}</html>"
shutdown_event = asyncio.Event()
async def test(loop):
print("Test")
async with async_playwright() as p:
print("Start")
browser = await p.chromium.launch()
context = await browser.new_context(device_scale_factor=1)
page = await context.new_page()
print("Page created")
await page.goto("http://localhost:5000")
print("Goto page")
await page.screenshot(path="hello.png", type='png')
print("Finished")
shutdown_event.set()
config = Config()
config.bind = ["localhost:5000"]
def save():
loop = asyncio.get_event_loop()
loop.create_task(test(loop))
loop.run_until_complete(
serve(app, config, shutdown_trigger=shutdown_event.wait)
)
print("End")
return save
make_message("Hello world")()
make_message("Me again")() # No error
Actual behavior
I got this error :
Test
[2024-02-04 22:05:29 +0100] [36736] [INFO] Running on http://127.0.0.1:5000 (CTRL + C to quit)
Start
Page created
Goto page
Finished
End
Test
[2024-02-04 22:05:29 +0100] [36736] [INFO] Running on http://127.0.0.1:5000 (CTRL + C to quit)
End
node:events:496
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
at Socket._writeGeneric (node:net:952:11)
at Socket._write (node:net:964:8)
at writeOrBuffer (node:internal/streams/writable:564:12)
at _write (node:internal/streams/writable:493:10)
at Writable.write (node:internal/streams/writable:502:10)
at PipeTransport.send (/home/nut/github/detroit/.venv/lib/python3.9/site-packages/playwright/driver/package/lib/protocol/transport.js:51:21)
at dispatcherConnection.onmessage (/home/nut/github/detroit/.venv/lib/python3.9/site-packages/playwright/driver/package/lib/cli/driver.js:53:57)
at DispatcherConnection._sendMessageToClient (/home/nut/github/detroit/.venv/lib/python3.9/site-packages/playwright/driver/package/lib/server/dispatchers/dispatcher.js:216:10)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
Node.js v20.11.0
Additional context
No response
Environment
System:
OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz
Memory: 6.21 GB / 15.52 GB
Container: Yes
Binaries:
Node: 14.21.3 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 6.14.18 - /usr/bin/npm
Languages:
Bash: 5.0.17 - /usr/bin/bash
clemlesne
Metadata
Metadata
Assignees
Labels
No labels