Code Monkey home page Code Monkey logo

Comments (1)

devl00p avatar devl00p commented on May 28, 2024

Hello ! I saw that error too.

Here is a simple code to reproduce:

import asyncio

from arsenic import get_session, browsers, services

async def launch_browser():
    service = services.Geckodriver()
    browser = browsers.Firefox(
        acceptInsecureCerts=True,
    )

    async with get_session(service, browser) as session:
        await session.get('http://127.0.0.1:8000/index.php', timeout=5)
        page_source = await session.get_page_source()

async def main():
    await asyncio.gather(
        launch_browser(),
    )

asyncio.run(main())

Here the timeout is set to 5 for arsenic. The php script is sleeping for 6 seconds:

<?php
sleep(6);
?>

Traceback:

Traceback (most recent call last):
  File "/tmp/headless/arsenic_single_req.py", line 27, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/tmp/headless/arsenic_single_req.py", line 23, in main
    await asyncio.gather(
  File "/tmp/headless/arsenic_single_req.py", line 19, in launch_browser
    await session.get('http://127.0.0.1:8000/index.php', timeout=5)
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib/python3.10/site-packages/arsenic/session.py", line 152, in get
    await self._request(
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib/python3.10/site-packages/arsenic/session.py", line 40, in _request
    status, data = await self.connection.request(
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib/python3.10/site-packages/arsenic/connection.py", line 55, in wrapper
    return await asyncio.get_event_loop().create_task(func(*args, **kwargs))
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib/python3.10/site-packages/arsenic/connection.py", line 103, in request
    async with self.session.request(
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib64/python3.10/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib64/python3.10/site-packages/aiohttp/client.py", line 559, in _request
    await resp.start(conn)
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib64/python3.10/site-packages/aiohttp/client_reqrep.py", line 893, in start
    with self._timer:
  File "/home/sirius/.local/share/virtualenvs/headless-C7_0qtPd/lib64/python3.10/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError

Also that timeout is not raised after the delay given to the timeout argument so if the page waits 30 secs the timeout is raised after 30secs, not 5 secs

Behavior seen:

  • the timeout parameter given to session.get was not used
  • an asyncio exception (from asyncio.exceptions was raised)

Expected behavior:

  • a timeout exception is raised as soon as the specified timeout is reached
  • an arsenic exception is raised (ArsenicTimeout)

Versions used:

  • arsenic==21.8
  • Python 3.10.6
  • geckodriver 0.26.0 (e9783a644016 2019-10-10 13:38 +0000)
  • Firefox 104.0 (64 bits)

from arsenic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.