Re: [python-tulip] TLS/SSL Wrapping

2014-04-06 Thread Guido van Rossum
I am trying to focus on how it should be done in terms of asyncio terms,
but I don't have time to actually write any code ATM.

It is better not to think of this (at first) in terms of
StreamReader/StreamWriter but in terms of the protocol and transport and
the event loop's create_connection() method. Wrapping
StreamReader/StreamWriter around the low-level objects will be obvious once
the low-level puzzle has been solved.

Please read the asyncio code for ssl transports and try to adapt it to your
needs; it already knows how to call wrap_socket() and do the handshake
asynchronously, so the right approach must be somewhere there. And my hunch
is that a very small refactoring might be enough.


On Sun, Apr 6, 2014 at 6:47 AM, Imran Geriskovan imran.gerisko...@gmail.com
 wrote:

 On 4/6/14, Guido van Rossum gu...@python.org wrote:
  Hm, I wonder if there isn't an even simpler approach that even works with
  the current asyncio public API. You can pass an already-open socket to
  create_connection() -- maybe you can use this (also passing
 ssl=context)
  and it would just work?

 Its possible. But that needs manual manupulation of the socket outside
 the asyncio domain. It is ugly. (sync code, selects, timeouts etc..)
 This undermines the reason for using asyncio.

 I thought about another possibility:

 StreamWriter.transport.get_extra_info('socket') gives access to the socket.
 That socket may be manually wrapped. Can you confirm if this operation
 is safe? But again here we have to handle the Handshake syncronously
 which is ugly too.

 I think there is no quick solution other than proper handling of the whole
 wrapping process in asyncio terms.

 Regards,
 Imran




-- 
--Guido van Rossum (python.org/~guido)


Re: [python-tulip] Present ZeroMQ integration and new Postgres client

2014-04-06 Thread Andrew Svetlov
Sorry, link for aiozmq is http://aiozmq.readthedocs.org/

On Sun, Apr 6, 2014 at 8:41 PM, Andrew Svetlov andrew.svet...@gmail.com wrote:
 I glad to present new libraries:
 aiozmq -- integration with ZeroMQ sockets (http://aiopg.readthedocs.org)
 aiopg -- Postgres client (http://aiopg.readthedocs.org)

 Libs have good test coverage and some documentation.

 While I have some plans for improvement of both libraries you can start to
 use it -- new versions will not break backward compatibility.

 Thanks,
 Andrew Svetlov.



-- 
Thanks,
Andrew Svetlov


Re: [python-tulip] Improper asyncio installation

2014-04-06 Thread Aymeric Augustin
On 6 avr. 2014, at 20:45, Subhendu Ghosh subho@gmail.com wrote:

 how to install asyncio correctly? any help welcome. Thank you.

You’re using Python 2.7, asyncio requires Python 3.3.

-- 
Aymeric.






Re: [python-tulip] TLS/SSL Wrapping

2014-04-06 Thread Imran Geriskovan
Thanks for the quidance.

selector_events.py : _SelectorSslTransport : __init__ wraps the socket
and postpones handshake. There is not much asyncio terms here..

Then it delegates to '_on_handshake' which has much of the asyncio stuff..
However, 'Under the hood' modification you've pointed is probably
beyond my abilities.

Actually I'm still thinking in terms of Streams, because they make life
easier.

Parallel to above partitioning I guess we need something like this:

sStream = ssl_wrap(Stream)
yield from sStream.do_handshake()

Regards,
Imran


Re: [python-tulip] Improper asyncio installation

2014-04-06 Thread Victor Stinner
You should install Trollius, not asyncio.

Victor

Le dimanche 6 avril 2014, Subhendu Ghosh subho@gmail.com a écrit :

 Hi all, I am trying to make a chat app using pulsar and django. asyncio is
 a dependency as you can see below.

 [subho@localhost djangoapp]$ python manage.py pulse
 Traceback (most recent call last):
   File manage.py, line 56, in module
 execute_from_command_line()
   File
 /usr/lib/python2.7/site-packages/django/core/management/__init__.py, line
 453, in execute_from_command_line
 utility.execute()
   File
 /usr/lib/python2.7/site-packages/django/core/management/__init__.py, line
 392, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File
 /usr/lib/python2.7/site-packages/django/core/management/__init__.py, line
 272, in fetch_command
 klass = load_command_class(app_name, subcommand)
   File
 /usr/lib/python2.7/site-packages/django/core/management/__init__.py, line
 77, in load_command_class
 module = import_module('%s.management.commands.%s' % (app_name, name))
   File /usr/lib/python2.7/site-packages/django/utils/importlib.py, line
 35, in import_module
 __import__(name)
   File /usr/lib/python2.7/site-packages/pulsar/__init__.py, line 58, in
 module
 from .async import *
   File /usr/lib/python2.7/site-packages/pulsar/async/__init__.py, line
 2, in module
 from .access import *
   File /usr/lib/python2.7/site-packages/pulsar/async/access.py, line 8,
 in module
 import asyncio
 ImportError: No module named asyncio
 [subho@localhost djangoapp]$ pwd
 /home/subho/Downloads/flareGet/Compressed/pulsar-0.8.0/examples/djangoapp

 So i tried installing asyncio

 [subho@localhost djangoapp]$ sudo pip install asyncio
 Downloading/unpacking asyncio
   Downloading asyncio-0.4.1.tar.gz (150kB): 150kB downloaded
   Running setup.py egg_info for package asyncio

 Installing collected packages: asyncio
   Running setup.py install for asyncio
   File /usr/lib/python2.7/site-packages/asyncio/base_events.py, line
 116
 yield from waiter
  ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/base_subprocess.py,
 line 73
 _, pipe = yield from loop.connect_write_pipe(
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/events.py, line 181
 def getaddrinfo(self, host, port, *, family=0, type=0, proto=0,
 flags=0):
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/futures.py, line 140
 def __init__(self, *, loop=None):
 ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/locks.py, line 96
 def __init__(self, *, loop=None):
 ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/queues.py, line 37
 def __init__(self, maxsize=0, *, loop=None):
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/selector_events.py,
 line 41
 def _make_socket_transport(self, sock, protocol, waiter=None, *,
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/selectors.py, line 39
 {!r}.format(fileobj)) from None
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/streams.py, line 37
 def open_connection(host=None, port=None, *,
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/subprocess.py, line
 106
 yield from waiter
  ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/tasks.py, line 86
 res = yield from res
^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/test_utils.py, line
 124
 def _run_test_server(*, address, use_ssl=False, server_cls,
 server_ssl_cls):
   ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/unix_events.py, line
 158
 yield from transp._post_init()
  ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/windows_events.py,
 line 38
 def __init__(self, ov, *, loop=None):
 ^
 SyntaxError: invalid syntax

   File /usr/lib/python2.7/site-packages/asyncio/windows_utils.py,
 line 64
 def pipe(*, duplex=False, overlapped=(True, True),
 bufsize=BUFSIZE):
   ^
 SyntaxError: invalid syntax


 Successfully installed asyncio
 Cleaning up...
 [subho@localhost djangoapp]$ python