Coder Social home page Coder Social logo

Comments (11)

1st1 avatar 1st1 commented on May 13, 2024

No, uvloop should behave exactly as vanilla asyncio. Would it be possible for you to make a failing unittest similar to other subprocess tests in 'uvloop/tests/'?

from uvloop.

lsbardel avatar lsbardel commented on May 13, 2024

I'm not sure how to do that! 😞

The issue occurs only when I press Ctril-C on the shell.

If I send SIGINT/SIGTERM to the main process not using Ctrl-C, everything works as expected.
You can see it yourself by running this script:

pip install git+http://github.com/quantmind/pulsar.git@coroactor#egg=pulsar uvloop
py scripy.py --io uv

where script.py is

from pulsar import MethodNotAllowed
from pulsar.apps import wsgi


def hello(environ, start_response):
    '''The WSGI_ application handler which returns an iterable
    over the "Hello World!" message.'''
    if environ['REQUEST_METHOD'] == 'GET':
        data = b'Hello World!\n'
        status = '200 OK'
        response_headers = [
            ('Content-type', 'text/plain'),
            ('Content-Length', str(len(data)))
        ]
        start_response(status, response_headers)
        return iter([data])
    else:
        raise MethodNotAllowed


def server(description=None, **kwargs):
    '''Create the :class:`.WSGIServer` running :func:`hello`.'''
    description = description or 'Pulsar Hello World Application'
    return wsgi.WSGIServer(hello, description=description, **kwargs)


if __name__ == '__main__':  # pragma nocover
    server().start()

Try to Ctrl-C and wait for about 5 seconds.
Than test with the vanilla asyncio loops

py script.py

or

py script.py --io select

from uvloop.

1st1 avatar 1st1 commented on May 13, 2024

Alright, I'll take a look in a few days!

from uvloop.

1st1 avatar 1st1 commented on May 13, 2024

I'm trying to figure out what's going on here and have some questions about how Pulsar works. Could you please point out to the place where you fork/create subprocesses for actors?

from uvloop.

1st1 avatar 1st1 commented on May 13, 2024

I see, it looks like you just instantiate multiprocessing.Process class. In asyncio, it's more reliable to use loop.subprocess_exec for that (at least that's what uvloop is tuned for).

from uvloop.

lsbardel avatar lsbardel commented on May 13, 2024

Right, that is what I suspected.
Pulsar was born before asyncio, that is why multiprocessing module is used for process-based actors.
I will have to look into the subprocess_exec method and see what exactly does and compare with multiprocessing.

from uvloop.

lsbardel avatar lsbardel commented on May 13, 2024

OK, using asyncio subprocess_exec fixes the issue.
Looks like the multiprocessing won't be used directly by pulsar anymore (I still need it for sharing server sockets between processes)

from uvloop.

1st1 avatar 1st1 commented on May 13, 2024

Great! I ended up rewriting how signals handling is implemented in uvloop from scratch. Maybe multiprocessing will work just fine when I'm done.

from uvloop.

1st1 avatar 1st1 commented on May 13, 2024

@lsbardel Please try uvloop 0.5.4. Ctrl-C is now being handled exactly as in asyncio.

from uvloop.

lsbardel avatar lsbardel commented on May 13, 2024

Yes it works! Nice one.
Pulsar 1.5 will have two ways of doing multiprocessing, via asyncio subprocess or multiprocessing module. The asyncio way is better because it does not block during forking.
In any case thanks for feedback and fixes.

from uvloop.

1st1 avatar 1st1 commented on May 13, 2024

@lsbardel Thanks for confirming that everything works now! Closing this issue.

from uvloop.

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.