Comments (11)
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.
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.
Alright, I'll take a look in a few days!
from uvloop.
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.
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.
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.
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.
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.
@lsbardel Please try uvloop 0.5.4. Ctrl-C is now being handled exactly as in asyncio.
from uvloop.
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.
@lsbardel Thanks for confirming that everything works now! Closing this issue.
from uvloop.
Related Issues (20)
- Python 3.12 Support for uvloop HOT 22
- uvloop installs generated loop.c file
- Can we update cython and make uvloop compatible with python 3.12 please? HOT 1
- test_cython_coro_is_coroutine: python: Objects/codeobject.c:771: PyCode_Addr2Line: Assertion `addrq >= 0 && addrq < _PyCode_NBYTES(co)' failed. HOT 1
- `__init__.pyi` added on #570 breaks mypy HOT 6
- [ALTLinux] [ppc64le] [0.18.0] `AssertionError: Didn't reach a full buffer` HOT 2
- [0.18.0] Running black causes core dump: src/unix/core.c:633: uv__close: Assertion `fd > 2' failed. HOT 5
- Idea: changing libuv not to install a signal handler
- Incorrect typing for set_task_factory HOT 1
- Please upgrade cython (3.0.x) HOT 8
- Possible to add `_start_tls_compatible` attribute to `TCPTransport`?
- Current version of libuv HOT 1
- Embedded Python interpreter in a C++ application making use of libuv
- UDPTransport returning when data is empty
- pipes from subprocess_exec do not have extra info 'pipe' (incompatible with vanilla asyncio) HOT 1
- libuv 1.48.0: getaddrinfo('', 0): OSError: [Errno 22] Invalid argument HOT 5
- Type annotations
- Server.serve_forever() isn't cancelled when Server.close() is called
- uvloop fails to build with Python 3.13.0a5: error: implicit declaration of function ‘_Py_RestoreSignals’ HOT 2
- Qualify claim of being drop-in replacement to asyncio
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uvloop.