saghul / aiouv Goto Github PK
View Code? Open in Web Editor NEWA PEP-3156 compatible event loop
A PEP-3156 compatible event loop
This is how I would like to see the future of rose/pyuv:
I try to use aiohttp
with aiouv
but get many "Logging error" messages like this when PYTHONASYNCIODEBUG is enabled:
DEBUG:asyncio:Get address info api.github.com:443, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info api.github.com:443, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1> took 87.464 ms: [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('192.30.252.127', 443))]
DEBUG:asyncio:connect <socket.socket fd=9, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('0.0.0.0', 0)> to ('192.30.252.127', 443)
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.5/logging/__init__.py", line 980, in emit
msg = self.format(record)
File "/usr/lib/python3.5/logging/__init__.py", line 830, in format
return fmt.format(record)
File "/usr/lib/python3.5/logging/__init__.py", line 567, in format
record.message = record.getMessage()
File "/usr/lib/python3.5/logging/__init__.py", line 330, in getMessage
msg = msg % self.args
File "/usr/lib/python3.5/asyncio/selector_events.py", line 537, in __repr__
polling = _test_selector_event(self._loop._selector,
AttributeError: 'EventLoop' object has no attribute '_selector'
Call stack:
File "a.py", line 27, in <module>
content = loop.run_until_complete(task)
File "/tmp/python/lib/python3.5/site-packages/aiouv/_events.py", line 80, in run_until_complete
self.run_forever()
File "/tmp/python/lib/python3.5/site-packages/aiouv/_events.py", line 71, in run_forever
self._run(pyuv.UV_RUN_DEFAULT)
File "/tmp/python/lib/python3.5/site-packages/aiouv/_events.py", line 458, in _run
r = self._loop.run(mode)
File "/tmp/python/lib/python3.5/site-packages/aiouv/_events.py", line 541, in _process_ready
handler._run()
File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
self._callback(*self._args)
File "/usr/lib/python3.5/asyncio/tasks.py", line 293, in _wakeup
self._step(value, None)
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(value)
File "a.py", line 18, in fetch
response = await aiohttp.get(url, loop=loop)
File "/tmp/python/lib/python3.5/site-packages/aiohttp/client.py", line 474, in get
ret = yield from request(hdrs.METH_GET, url, **kwargs)
File "/tmp/python/lib/python3.5/site-packages/aiohttp/client.py", line 466, in request
read_until_eof=read_until_eof)
File "/tmp/python/lib/python3.5/site-packages/aiohttp/client.py", line 131, in request
conn = yield from self._connector.connect(req)
File "/tmp/python/lib/python3.5/site-packages/aiohttp/connector.py", line 292, in connect
transport, proto = yield from self._create_connection(req)
File "/tmp/python/lib/python3.5/site-packages/aiohttp/connector.py", line 571, in _create_connection
server_hostname=hinfo['hostname'] if sslcontext else None)
File "/usr/lib/python3.5/asyncio/base_events.py", line 669, in create_connection
sock, protocol_factory, ssl, server_hostname)
File "/usr/lib/python3.5/asyncio/base_events.py", line 687, in _create_connection_transport
server_side=False, server_hostname=server_hostname)
File "/tmp/python/lib/python3.5/site-packages/aiouv/_events.py", line 394, in _make_ssl_transport
return selector_events._SelectorSslTransport(self, rawsock, protocol, sslcontext, waiter, server_side, server_hostname, extra, server)
File "/usr/lib/python3.5/asyncio/selector_events.py", line 782, in __init__
logger.debug("%r starts SSL handshake", self)
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
How to reproduce:
#!/usr/bin/env python3.5
import logging
import os
import warnings
import aiohttp
import aiouv
os.environ['PYTHONASYNCIODEBUG'] = '1'
logging.basicConfig(level=logging.DEBUG)
warnings.resetwarnings()
async def fetch(url, loop):
r = await aiohttp.get(url, loop=loop)
r.close()
loop = aiouv.EventLoop()
try:
loop.run_until_complete(fetch('https://api.github.com/events', loop=loop))
finally:
loop.close()
print("Stopped!")
It possible either EventLoop
shold be compatible with SelectorEventLoop
(#11) or EventLoop
shouldn't use any _Selector*Transport
directly because they expect SelectorEventLoop
.
Hi,
I'm preparing a commit with a setup.py, but I have an issue on PyPI: rose is already taken:
https://pypi.python.org/pypi/rose
Personally, I'm not a big fan to have a different name on PyPI and on Github, I suggest to rename rose directly to avoid problems.
Some suggestions: aiorose, aiouv, asyncio_rose, asyncio_pyuv, pyuv_rose...
What's your opinion ?
import aiouv
aiouv.create_udp_endpoint(aiouv.EventLoop(), lambda *a:None, remote_addr=('127.0.0.1', 6001))
Exception:
Traceback (most recent call last):
File "<pyshell#3>", line 2, in <module>
aiouv.create_udp_endpoint(aiouv.EventLoop(), lambda *a:None, remote_addr=('127.0.0.1', 6001))
File "d:\aiouv\aiouv\_transports.py", line 297, in create_udp_endpoint
addr = handle.getsockname()
pyuv._cpyuv.error.UDPError: (-4071, 'invalid argument')
It's almost done, I've fixed all tests I can.
@Haypo has planned to change aiotest to avoid to access to self.loop._selector
attribute.
If you remove _selector attribute failures, only test_soon_stop_soon
doesn't pass, but the test is a little bit mystic for me. For me, the result produced by aiouv
is more logical.
If I understand correctly, aiotest is enough to validate PEP 3156.
Could I remove runtests.py or some tests from AsyncIO are necessary ?
Could I enable Travis-CI ?
Using the following:
asyncio.set_event_loop_policy(aiouv.EventLoopPolicy)
loop = asyncio.get_event_loop()
I get the following error:
Traceback (most recent call last):
File "app.py", line 140, in <module>
asyncio.set_event_loop_policy(aiouv.EventLoopPolicy)
File "/usr/lib/python3.5/asyncio/events.py", line 620, in set_event_loop_policy
assert policy is None or isinstance(policy, AbstractEventLoopPolicy)
AssertionError
Python 3.5.1+ (debian)
aiouv from git
Last week I modified SelectorEventLoop._accept_connection() to fix a bug (close the transport on error). I see that aiouv has copied an old copy (with the bug) of the function. Instead, aiouv should inherit from SelectorEventLoop, or we should retrieve the code differently.
At least, the bug should fix fixed: copy/paste the new code? :-(
aiouv's use of 'addr'
as the key name in the extra
kwarg for the Transport classes is inconsistent. One place it refers to the result of getsockname() (UDP transport) and others to the result of getpeername() (TCP transport).
Additionally, asyncio itself uses 'sockname'
and 'peername'
. (Example in library, mention in docs)
Suggesting key names are changed to match asyncio's usage.
Let me know your thoughts.
environment
(python343) D:\venv\python343\Scripts>pip install aiouv
Collecting aiouv
Could not find a version that satisfies the requirement aiouv (from versions:
)
No matching distribution found for aiouv
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.