File tree Expand file tree Collapse file tree 3 files changed +26
-26
lines changed Expand file tree Collapse file tree 3 files changed +26
-26
lines changed Original file line number Diff line number Diff line change 1
1
__version__ = "0.0.40"
2
-
3
-
4
- from ._utils import ensure_future # noqa: F401
5
- from .handler import ScrapyPlaywrightDownloadHandler # noqa: F401
6
- from .page import PageMethod # noqa: F401
Original file line number Diff line number Diff line change @@ -162,24 +162,3 @@ def stop(cls, caller_id: int) -> None:
162
162
asyncio .run_coroutine_threadsafe (cls ._coro_queue .join (), cls ._loop )
163
163
cls ._loop .call_soon_threadsafe (cls ._loop .stop )
164
164
cls ._thread .join ()
165
-
166
-
167
- def ensure_future (coro : Awaitable ) -> asyncio .Future :
168
- """Wrap a coroutine in a Future assigned to the threaded event loop.
169
-
170
- On windows, Playwright runs in an event loop of its own in a separate thread.
171
- If Playwright coroutines are awaited directly, they are assigned to the main
172
- thread's event loop, resulting in: "ValueError: The future belongs to a
173
- different loop than the one specified as the loop argument"
174
-
175
- Usage:
176
- ```
177
- from playwright.async_api import Page
178
- from scrapy_playwright import ensure_future
179
-
180
- async def parse(self, response):
181
- page: Page = response.meta["playwright_page"]
182
- await ensure_future(page.screenshot(path="example.png", full_page=True))
183
- ```
184
- """
185
- return _ThreadedLoopAdapter ._ensure_future (coro )
Original file line number Diff line number Diff line change
1
+ import asyncio
2
+
3
+ from typing import Awaitable
4
+
5
+ from ._utils import _ThreadedLoopAdapter
6
+
7
+
8
+ def ensure_future (coro : Awaitable ) -> asyncio .Future :
9
+ """Wrap a coroutine in a Future assigned to the threaded event loop.
10
+
11
+ On windows, Playwright runs in an event loop of its own in a separate thread.
12
+ If Playwright coroutines are awaited directly, they are assigned to the main
13
+ thread's event loop, resulting in: "ValueError: The future belongs to a
14
+ different loop than the one specified as the loop argument"
15
+
16
+ Usage:
17
+ ```
18
+ from playwright.async_api import Page
19
+ from scrapy_playwright import ensure_future
20
+
21
+ async def parse(self, response):
22
+ page: Page = response.meta["playwright_page"]
23
+ await ensure_future(page.screenshot(path="example.png", full_page=True))
24
+ ```
25
+ """
26
+ return _ThreadedLoopAdapter ._ensure_future (coro )
You can’t perform that action at this time.
0 commit comments