GithubHelp home page GithubHelp logo

aionursery's People

Contributors

malinoff avatar sobolevn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aionursery's Issues

Task never finish if exception raise in another task

To reproduce:

# coding: utf-8
import aionursery
import asyncio


async def foo(i):
    if i == 2:
        1/0
    if i == 1:
        print("1 sleeping ...")
        await asyncio.sleep(0.1)
        print("1 OK")
    print(i)


async def main():
    try:
        async with aionursery.Nursery() as start_nursery:
            for i in range(10):
                start_nursery.start_soon(foo(i))
    except aionursery.MultiError as exc:
        print(f"MultiError: {exc}")


asyncio.run(main())

Output:

0
1 sleeping ...
3
4
5
6
7
8
9
MultiError: [ZeroDivisionError('division by zero')]
Details of embedded exception 0:
  Traceback (most recent call last):
    File "<input>", line 8, in foo
  ZeroDivisionError: division by zero

print("1 OK") is never reach.

Wrong exception raised

Following behaviour is specified In README:

Any unhandled exceptions are re-raised inside the parent task. If there are multiple exceptions, then they’re collected up into a single MultiError exception.

That is not true. Actually aionursery will raise MultiError even if there is only one exception:

if self._pending_excs:
    raise MultiError(self._pending_excs)

I suggest to add appropriate condition to aionursery source code:

if len(self._pending_excs) == 1:
    raise self._pending_excs[0]

if self._pending_excs:
    raise MultiError(self._pending_excs)

It will simplify exception handling.

Deprecation warning under py3.7

/usr/local/lib/python3.7/site-packages/aionursery.py:61: PendingDeprecationWarning: Task.current_task() is deprecated, use asyncio.current_task() instead
    self._parent_task = asyncio.Task.current_task(self._loop)

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.