Skip to content

tests failing due to RuntimeError: called 'started' twice on the same task status #43

@alee

Description

@alee
platform linux -- Python 3.10.13, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/runner/work/skope-api/skope-api/timeseries
plugins: asyncio-0.21.1, anyio-4.0.0
asyncio: mode=strict
collected 19 items

app/tests/test_stores.py ..                                              [ 10%]
app/tests/routers/test_datasets.py ...............F.                     [100%]

=================================== FAILURES ===================================
_________________________________ test_timeout _________________________________

request = TimeseriesRequest(dataset_id='annual_5x5x5_dataset', variable_id='float32_variable', selected_area=SkopePointModel(typ...=NoSmoother(type='NoSmoother'))], time_range=OptionalTimeRange(gte=datetime.date(1, 1, 1), lte=datetime.date(5, 1, 1)))
dataset_manager = DatasetManager(datasets={'annual_5x5x5_dataset': Dataset(time_range=TimeRange(gte=datetime.date(1, 1, 1), lte=datetime...e=datetime.date(5, 12, 1)), variables={'int16_variable', 'float32_variable'}, resolution=<Resolution.month: 'month'>)})

    async def extract_timeseries(
        request: TimeseriesRequest, dataset_manager: DatasetManager
    ):
        timeout = request.max_processing_time
        logger.debug("setting request timeout to %s", timeout)
        async with create_task_group() as tg:
            try:
                with fail_after(timeout) as scope:
                    output = {"response": {}}
>                   await tg.start(
                        extract_timeseries_task, request, dataset_manager, output
                    )

app/core/services.py:196: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py:770: in start
    await task
app/core/services.py:211: in extract_timeseries_task
    task_status.started()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <anyio._backends._asyncio._AsyncioTaskStatus object at 0x7ffa93dfafe0>
value = None

    def started(self, value: T_contra | None = None) -> None:
        try:
            self._future.set_result(value)
        except asyncio.InvalidStateError:
>           raise RuntimeError(
                "called 'started' twice on the same task status"
            ) from None
E           RuntimeError: called 'started' twice on the same task status

/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py:601: RuntimeError

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line 196, in extract_timeseries
    await tg.start(
  File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 770, in start
    await task
  File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line 211, in extract_timeseries_task
    task_status.started()
  File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 601, in started
    raise RuntimeError(
RuntimeError: called 'started' twice on the same task status

During handling of the above exception, another exception occurred:

  + Exception Group Traceback (most recent call last):
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/runner.py", line 341, in from_call
  |     result: Optional[TResult] = func()
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/runner.py", line 262, in <lambda>
  |     lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_hooks.py", line 493, in __call__
  |     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_manager.py", line 1[15](https://github.com/openskope/skope-api/actions/runs/6490982769/job/17627582269#step:5:16), in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 152, in _multicall
  |     return outcome.get_result()
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_result.py", line 114, in get_result
  |     raise exc.with_traceback(exc.__traceback__)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 77, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/runner.py", line 177, in pytest_runtest_call
  |     raise e
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/runner.py", line [16](https://github.com/openskope/skope-api/actions/runs/6490982769/job/17627582269#step:5:17)9, in pytest_runtest_call
  |     item.runtest()
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/python.py", line [17](https://github.com/openskope/skope-api/actions/runs/6490982769/job/17627582269#step:5:18)92, in runtest
  |     self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_hooks.py", line 493, in __call__
  |     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_manager.py", line 115, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 152, in _multicall
  |     return outcome.get_result()
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_result.py", line 114, in get_result
  |     raise exc.with_traceback(exc.__traceback__)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 77, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/python.py", line [19](https://github.com/openskope/skope-api/actions/runs/6490982769/job/17627582269#step:5:20)4, in pytest_pyfunc_call
  |     result = testfunction(**testargs)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pytest_asyncio/plugin.py", line 532, in inner
  |     _loop.run_until_complete(task)
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
  |     return future.result()
  |   File "/home/runner/work/skope-api/skope-api/timeseries/app/tests/routers/test_datasets.py", line 152, in test_timeout
  |     response = await extract_timeseries(maq, dataset_manager)
  |   File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line 192, in extract_timeseries
  |     async with create_task_group() as tg:
  |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 664, in __aexit__
  |     raise BaseExceptionGroup(
  | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line 196, in extract_timeseries
    |     await tg.start(
    |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 770, in start
    |     await task
    |   File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line [21](https://github.com/openskope/skope-api/actions/runs/6490982769/job/17627582269#step:5:22)1, in extract_timeseries_task
    |     task_status.started()
    |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 601, in started
    |     raise RuntimeError(
    | RuntimeError: called 'started' twice on the same task status
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line 196, in extract_timeseries
    |     await tg.start(
    |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 770, in start
    |     await task
    |   File "/home/runner/work/skope-api/skope-api/timeseries/app/core/services.py", line 211, in extract_timeseries_task
    |     task_status.started()
    |   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line [60](https://github.com/openskope/skope-api/actions/runs/6490982769/job/17627582269#step:5:61)1, in started
    |     raise RuntimeError(
    | RuntimeError: called 'started' twice on the same task status

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions