Skip to content

Commit 9c8274a

Browse files
committed
test: assert the events websocket shutdown e2e test really crawled
1 parent 1b7132c commit 9c8274a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tests/e2e/test_actor_events.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,16 @@ async def test_events_websocket_shutdown_is_clean(
141141
async def main() -> None:
142142
from crawlee.crawlers import ParselCrawler, ParselCrawlingContext
143143

144-
# The crawler run keeps the event loop busy, so an unclosed events websocket iterator would be
145-
# garbage-collected only during interpreter shutdown - the timing that triggers the error.
144+
# A real crawler run is needed: the concurrency around Actor exit is what leaves an unclosed events
145+
# websocket iterator's finalizer still in flight when the event loop tears down.
146146
async with Actor:
147+
assert Actor.configuration.actor_events_ws_url, 'The run must use the platform events websocket.'
148+
147149
crawler = ParselCrawler(max_crawl_depth=2)
148150

149151
@crawler.router.default_handler
150152
async def handler(context: ParselCrawlingContext) -> None:
153+
await context.push_data({'url': context.request.url})
151154
await context.enqueue_links()
152155

153156
await crawler.run(['http://localhost:8080/'])
@@ -156,7 +159,10 @@ async def handler(context: ParselCrawlingContext) -> None:
156159
run_result = await run_actor(actor)
157160

158161
assert run_result.status == 'SUCCEEDED'
159-
assert run_result.exit_code == 0
162+
163+
# The log assertions below are negative, so confirm the crawl that drives them really visited pages.
164+
dataset_items_page = await actor.last_run().dataset().list_items()
165+
assert dataset_items_page.count > 1
160166

161167
run_log = await actor.last_run().log().get()
162168
assert run_log is not None

0 commit comments

Comments
 (0)