[Tutor] asyncio and wsgiref problem

2017-11-08 Thread Etienne Robillard

Hi,

I'm trying to implement the asyncio.coroutine decorator in my wsgi app.

Here's my server code:

class AsyncIOController(WSGIController):
def __init__(self, settings=None, executor=None, loop=None
):
super(AsyncIOController, self).__init__(settings)
# asyncio config.
self._executor = executor
self._loop = loop or get_event_loop()

#@asyncio.coroutine
def get_response(self, request=None, method='GET', data={}):
response = super(AsyncIOController, self).get_response(request)
return response

@asyncio.coroutine
def application(self, environ, start_response):
with sessionmanager(environ):
request.environ.update(environ)
response = self.get_response(request=request)(environ, 
start_response)

#assert isinstance(response, bytes), type(response)
return response

@asyncio.coroutine
def __call__(self, environ, start_response, exc_info=None):
result = self.application(environ, start_response)
return result

My test script:


@asyncio.coroutine
def app(environ, start_response):
try:
result = (yield from AsyncIOController().application(environ, 
start_response))

return result
except:
raise

if __name__ == '__main__':
server = simple_server.make_server('127.0.0.1', 8000, app)
server.serve_forever()

Should I attempt to decorate the AsyncIOController.get_response method 
with the asyncio.coroutine method ?


Any ideas how to fix this script ?

Thank you in advance,

Etienne

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Visual Studio issue when pip installing mysql-python

2017-11-08 Thread Mike Nickey
Hi all,

I understand that this might be out of the scope of this list but I am
hopeful that someone has some insight on it so I can move forward with this
project. This is a hail mary attempt to get this resolved.

The issue that I am seeing is that I have a script that works well locally.
I am trying to get this to work on a virtual machine (Windows Server
2012R).
I the goal of this is to have the virtual machine run this automatically
for us.

When I am installing the dependancies for this script I am running into an
issue with :
pip install mysql-python

The full Traceback is rather long but I can post it if needed.

building '_mysql' extension
creating build\temp.win-amd64-3.4
creating build\temp.win-amd64-3.4\Release
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe
/c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1)
-D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C
6.0.2\include" -IC:\Python34\include -IC:\Python34\include /Tc_mysql.c
/Fobuild\temp.win-amd64-3.4\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(42) : fatal error C1083: Cannot open include file:
'config-win.h': No such file or directory
error: command '"c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\BIN\amd64\cl.exe"' failed with exit status 2

Any ideas on how to resolve this?
I've already asked to have a linux virtual machine spun up for us but I'd
love to hear what you think.

-- 
~MEN
Portfolio 
Schedule a meeting  with me!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visual Studio issue when pip installing mysql-python

2017-11-08 Thread Mats Wichmann
On 11/08/2017 01:59 PM, Mike Nickey wrote:
> Hi all,
> 
> I understand that this might be out of the scope of this list but I am
> hopeful that someone has some insight on it so I can move forward with this
> project. This is a hail mary attempt to get this resolved.
> 
> The issue that I am seeing is that I have a script that works well locally.
> I am trying to get this to work on a virtual machine (Windows Server
> 2012R).
> I the goal of this is to have the virtual machine run this automatically
> for us.
> 
> When I am installing the dependancies for this script I am running into an
> issue with :
> pip install mysql-python
> 
> The full Traceback is rather long but I can post it if needed.
> 
> building '_mysql' extension
> creating build\temp.win-amd64-3.4
> creating build\temp.win-amd64-3.4\Release
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe
> /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1)
> -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C
> 6.0.2\include" -IC:\Python34\include -IC:\Python34\include /Tc_mysql.c
> /Fobuild\temp.win-amd64-3.4\Release\_mysql.obj /Zl
> _mysql.c
> _mysql.c(42) : fatal error C1083: Cannot open include file:
> 'config-win.h': No such file or directory
> error: command '"c:\Program Files (x86)\Microsoft Visual Studio
> 10.0\VC\BIN\amd64\cl.exe"' failed with exit status 2
> 
> Any ideas on how to resolve this?
> I've already asked to have a linux virtual machine spun up for us but I'd
> love to hear what you think.


Can't answer for you, not being a VS, or even Windows, guy, but a couple
of notes:
- people have been having problems with the mysql config-win.h for
years. I bet you'll have some fun if you search for this on Stack Exchange.
- VS 10.0 is _awfully_ old.  If you're intentionally trying to use this
version - don't.  If it's falling over because of the VS tendency to try
to support the whole world at once, I have no idea how to help you avoid
that. You probably only want to intentionally support roughly [12.0 (aka
VS 2013), 14.0 (aka VS 2015), 15.0 (aka CS 2017)]

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] asyncio and wsgiref problem

2017-11-08 Thread Etienne Robillard

This code is compatible with PEP- on Python 3.5.3:

@asyncio.coroutine
def app(environ, start_response):
try:
result = (yield from AsyncIOController().application(environ, 
start_response))

except:
raise
else:

#XXX result is a generator. this should not be needed?

yield from result

I updated my server code like so:

class AsyncIOController(WSGIController):
def __init__(self, settings=None, executor=None, loop=None
):
super(AsyncIOController, self).__init__(settings)
# asyncio config.
self._executor = executor
self._loop = loop or get_event_loop()

#@asyncio.coroutine
def get_response(self, request=None, method='GET', data={}):
response = super(AsyncIOController, self).get_response(request)
return response

@asyncio.coroutine
def application(self, environ, start_response):
with sessionmanager(environ):
request.environ.update(environ)
response = self.get_response(request=request)
#assert isinstance(response, bytes), type(response)
return response(environ, start_response)

@asyncio.coroutine
def __call__(self, environ, start_response, exc_info=None):
result = self.application(environ, start_response)
return result

How can i avoid calling "yield" twice in my test script ?

Thank you,

Etienne

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor