Re: [web2py] Re: Nginx, uwsgi, on Windows

2016-04-21 Thread Kiran Subbaraman
The module (which included grequests) was being used in a web2py and 
non-web2py context. The grequest capability was coming into play in the 
latter context.

Refactored by separating out this responsibility.


Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Thu, 21-04-2016 5:45 PM, Niphlod wrote:
why would you use a library made to use gevent in an environment that 
doesn't support it ?
if you need to use gevent-coroutines-etc-etc-etc you need to have the 
COMPLETE env supporting it, not just a piece.


On Thursday, April 21, 2016 at 7:49:25 AM UTC+2, Kiran Subbaraman wrote:

Narrowed down the issue. Basically, the grequests modules that I
was using seems to be the cause of the "|LoopExit: This operation
would block forever"|

Create an application: *redis_event*

*controller: default.py*
|
importcache_mod

defindex():
returndict(message=cache_mod.get_value())
|

*module: cache_mod.py*
|
importredis
importgrequests

redis_cache =redis.StrictRedis(host='localhost',port=6379,db=0)

defget_value(key='SOME_KEY'):
returnredis_cache.get(key)
|

view: index.html
|
{{=message}}
|

Once deployed on the server, access this url:
http://127.0.0.1:8000/redis_event/default/index

Reload the page successively - repeatedly F5 after page load - and
you will notice the error on the page.

Am moving away from grequests, and settling for just requests.



On Thursday, April 21, 2016 at 9:44:42 AM UTC+5:30, Kiran
Subbaraman wrote:

Thanks for the recommendation - IIS with web2py is a
recommended deployment on Windows.

The gevent-mix-up-with-rocket, was based on the stack trace I
pasted below. And like I mentioned, this connection was made
without any evidence ... so yeah, I was writing this before I
gave it too much thought or investigation.
In any case, I'll do some more investigation and try to track
down this issue.


Kiran Subbaraman
http://subbaraman.wordpress.com/about/


On Thu, 21-04-2016 3:42 AM, Niphlod wrote:

forget about uwsgi on windows. never really landed as
production-ready. fortunately iis can run python without any
hiccup and it's the current recommended way to deploy web2py
in production on windows.
that being said, I'm really eager to know how the hell you're
getting gevent mixed up with web2py's internal webserver,
which is not at all compatible with gevent. On Wednesday,
April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote:

Hello all, I use Windows 10 based laptop for my
development. By default, web2py serves its content via
the rocket server. My application makes use of the
'default' redis client () to connect to the local redis
server. I started noticing a stacktrace, in the cmd
prompt, from within which web2py has started:
|

CreatedbyMassimoDiPierro,Copyright2007-2016Version2.14.3-stable+timestamp.2016.03.26.17.54.43Databasedrivers

available:psycopg2,pymysql,imaplib,sqlite3,pg8000,pyodbc,mysqlconnector
please visit:http://127.0.0.1:8000/
starting browser...please visit: 
  http://127.0.0.1:8000/

starting
browser...2016-04-2020:26:54,003-Rocket.Errors.Port8000-ERROR
-Traceback(most recent call
last):File"d:\code\git\web2py\gluon\rocket.py",line
587,inlisten sock,addr

=self.listener.accept()File"D:\programs\open\python27\lib\site-packages\gevent\socket.py",line
316,inaccept

self._wait(self._read_event)File"D:\programs\open\python27\lib\site-packages\gevent\socket.py",line
300,in_wait

self.hub.wait(watcher)File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
348,inwait result

=waiter.get()File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line

575,ingetreturnself.hub.switch()File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
338,inswitchreturngreenlet.switch(self)LoopExit:Thisoperation
would block forever
|
The error in the error-ticket is:
|
This operation would block
forever Version web2py™ Version
2.14.3-stable+timestamp.2016.03.26.17.54.43 Python
Python 2.7.10: D:\programs\open\python27\python.exe

(prefix: D:\programs\open\python27) Traceback Traceback
 

Re: [web2py] Re: Nginx, uwsgi, on Windows

2016-04-21 Thread Niphlod
why would you use a library made to use gevent in an environment that 
doesn't support it ?
if you need to use gevent-coroutines-etc-etc-etc you need to have the 
COMPLETE env supporting it, not just a piece.

On Thursday, April 21, 2016 at 7:49:25 AM UTC+2, Kiran Subbaraman wrote:
>
> Narrowed down the issue. Basically, the grequests modules that I was using 
> seems to be the cause of the "LoopExit: This operation would block 
> forever"
>
> Create an application: *redis_event*
>
> *controller: default.py*
> import cache_mod
>
> def index():
> return dict(message=cache_mod.get_value())
>
> *module: cache_mod.py*
> import redis
> import grequests
>
> redis_cache = redis.StrictRedis(host='localhost', port=6379, db=0)
>
> def get_value(key='SOME_KEY'):
> return redis_cache.get(key)
>
> view: index.html
> {{=message}}
>
> Once deployed on the server, access this url: 
> http://127.0.0.1:8000/redis_event/default/index
> Reload the page successively - repeatedly F5 after page load - and you 
> will notice the error on the page.
>
> Am moving away from grequests, and settling for just requests.
>
>
>
> On Thursday, April 21, 2016 at 9:44:42 AM UTC+5:30, Kiran Subbaraman wrote:
>>
>> Thanks for the recommendation - IIS with web2py is a recommended 
>> deployment on Windows.
>>
>> The gevent-mix-up-with-rocket, was based on the stack trace I pasted 
>> below. And like I mentioned, this connection was made without any evidence 
>> ... so yeah, I was writing this before I gave it too much thought or 
>> investigation. 
>> In any case, I'll do some more investigation and try to track down this 
>> issue.
>>
>> 
>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>
>> On Thu, 21-04-2016 3:42 AM, Niphlod wrote:
>>
>> forget about uwsgi on windows. never really landed as production-ready. 
>> fortunately iis can run python without any hiccup and it's the current 
>> recommended way to deploy web2py in production on windows. 
>>
>> that being said, I'm really eager to know how the hell you're getting 
>> gevent mixed up with web2py's internal webserver, which is not at all 
>> compatible with gevent.
>>
>> On Wednesday, April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote: 
>>>
>>> Hello all,
>>> I use Windows 10 based laptop for my development. By default, web2py 
>>> serves its content via the rocket server. 
>>> My application makes use of the 'default' redis client () to connect to 
>>> the local redis server.
>>> I started noticing a stacktrace, in the cmd prompt, from within which 
>>> web2py has started:
>>> Created by Massimo Di Pierro, Copyright 2007-2016
>>> Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
>>> Database drivers available: psycopg2, pymysql, imaplib, sqlite3, pg8000, 
>>> pyodbc, mysqlconnector
>>> please visit:
>>> http://127.0.0.1:8000/
>>> starting browser...
>>> please visit:
>>> http://127.0.0.1:8000/
>>> starting browser...
>>> 2016-04-20 20:26:54,003 - Rocket.Errors.Port8000 - ERROR - Traceback (most 
>>> recent call last):
>>>   File "d:\code\git\web2py\gluon\rocket.py", line 587, in listen
>>> sock, addr = self.listener.accept()
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
>>> line 316, in accept
>>> self._wait(self._read_event)
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
>>> line 300, in _wait
>>> self.hub.wait(watcher)
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", 
>>> line 348, in wait
>>> result = waiter.get()
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", 
>>> line 575, in get
>>> return self.hub.switch()
>>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", 
>>> line 338, in switch
>>> return greenlet.switch(self)
>>> LoopExit: This operation would block forever
>>>
>>> The error in the error-ticket is:
>>>  This operation would block forever
>>> Version
>>> web2py™ Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
>>> Python Python 2.7.10: D:\programs\open\python27\python.exe (prefix: 
>>> D:\programs\open\python27)
>>> Traceback
>>>
>>>
>>> Traceback (most recent call last):
>>>   File "d:\code\git\web2py\gluon\restricted.py", line 227, in restricted
>>> exec ccode in environment
>>>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
>>> line 99, in 
>>>   File "d:\code\git\web2py\gluon\globals.py", line 417, in 
>>> self._caller = lambda f: f()
>>>   File "d:\code\git\web2py\gluon\cache.py", line 661, in wrapped_f
>>> rtn = func()
>>>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
>>> line 68, in data
>>> data = api.get_data(url)
>>>   File "applications\myapp\modules\data\api.py", line 145, in get_data
>>> return _get_data_for(url) if url else None
>>>   File "applications\myapp\modules\data\api.py", line 164, in 
>>> _get_data_for
>>> force_reload=rebuild
>>>   

Re: [web2py] Re: Nginx, uwsgi, on Windows

2016-04-20 Thread Kiran Subbaraman
Narrowed down the issue. Basically, the grequests modules that I was using 
seems to be the cause of the "LoopExit: This operation would block forever"

Create an application: *redis_event*

*controller: default.py*
import cache_mod

def index():
return dict(message=cache_mod.get_value())

*module: cache_mod.py*
import redis
import grequests

redis_cache = redis.StrictRedis(host='localhost', port=6379, db=0)

def get_value(key='SOME_KEY'):
return redis_cache.get(key)

view: index.html
{{=message}}

Once deployed on the server, access this url: 
http://127.0.0.1:8000/redis_event/default/index
Reload the page successively - repeatedly F5 after page load - and you will 
notice the error on the page.

Am moving away from grequests, and settling for just requests.



On Thursday, April 21, 2016 at 9:44:42 AM UTC+5:30, Kiran Subbaraman wrote:
>
> Thanks for the recommendation - IIS with web2py is a recommended 
> deployment on Windows.
>
> The gevent-mix-up-with-rocket, was based on the stack trace I pasted 
> below. And like I mentioned, this connection was made without any evidence 
> ... so yeah, I was writing this before I gave it too much thought or 
> investigation. 
> In any case, I'll do some more investigation and try to track down this 
> issue.
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Thu, 21-04-2016 3:42 AM, Niphlod wrote:
>
> forget about uwsgi on windows. never really landed as production-ready. 
> fortunately iis can run python without any hiccup and it's the current 
> recommended way to deploy web2py in production on windows. 
>
> that being said, I'm really eager to know how the hell you're getting 
> gevent mixed up with web2py's internal webserver, which is not at all 
> compatible with gevent.
>
> On Wednesday, April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote: 
>>
>> Hello all,
>> I use Windows 10 based laptop for my development. By default, web2py 
>> serves its content via the rocket server. 
>> My application makes use of the 'default' redis client () to connect to 
>> the local redis server.
>> I started noticing a stacktrace, in the cmd prompt, from within which 
>> web2py has started:
>> Created by Massimo Di Pierro, Copyright 2007-2016
>> Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
>> Database drivers available: psycopg2, pymysql, imaplib, sqlite3, pg8000, 
>> pyodbc, mysqlconnector
>> please visit:
>> http://127.0.0.1:8000/
>> starting browser...
>> please visit:
>> http://127.0.0.1:8000/
>> starting browser...
>> 2016-04-20 20:26:54,003 - Rocket.Errors.Port8000 - ERROR - Traceback (most 
>> recent call last):
>>   File "d:\code\git\web2py\gluon\rocket.py", line 587, in listen
>> sock, addr = self.listener.accept()
>>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
>> line 316, in accept
>> self._wait(self._read_event)
>>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
>> line 300, in _wait
>> self.hub.wait(watcher)
>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
>> 348, in wait
>> result = waiter.get()
>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
>> 575, in get
>> return self.hub.switch()
>>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
>> 338, in switch
>> return greenlet.switch(self)
>> LoopExit: This operation would block forever
>>
>> The error in the error-ticket is:
>>  This operation would block forever
>> Version
>> web2py™ Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
>> Python Python 2.7.10: D:\programs\open\python27\python.exe (prefix: 
>> D:\programs\open\python27)
>> Traceback
>>
>>
>> Traceback (most recent call last):
>>   File "d:\code\git\web2py\gluon\restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
>> line 99, in 
>>   File "d:\code\git\web2py\gluon\globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File "d:\code\git\web2py\gluon\cache.py", line 661, in wrapped_f
>> rtn = func()
>>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
>> line 68, in data
>> data = api.get_data(url)
>>   File "applications\myapp\modules\data\api.py", line 145, in get_data
>> return _get_data_for(url) if url else None
>>   File "applications\myapp\modules\data\api.py", line 164, in 
>> _get_data_for
>> force_reload=rebuild
>>   File "applications\myapp\modules\myapp_constants.py", line 460, in 
>> get_from_cache
>> cache_value = redis_cache.get(key)
>>   File "D:\programs\open\python27\lib\site-packages\redis\client.py", 
>> line 880, in get
>> return self.execute_command('GET', name)
>>   File "D:\programs\open\python27\lib\site-packages\redis\client.py", 
>> line 573, in execute_command
>> return self.parse_response(connection, 

Re: [web2py] Re: Nginx, uwsgi, on Windows

2016-04-20 Thread Kiran Subbaraman
Thanks for the recommendation - IIS with web2py is a recommended 
deployment on Windows.


The gevent-mix-up-with-rocket, was based on the stack trace I pasted 
below. And like I mentioned, this connection was made without any 
evidence ... so yeah, I was writing this before I gave it too much 
thought or investigation.
In any case, I'll do some more investigation and try to track down this 
issue.



Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Thu, 21-04-2016 3:42 AM, Niphlod wrote:
forget about uwsgi on windows. never really landed as 
production-ready. fortunately iis can run python without any hiccup 
and it's the current recommended way to deploy web2py in production on 
windows.


that being said, I'm really eager to know how the hell you're getting 
gevent mixed up with web2py's internal webserver, which is not at all 
compatible with gevent.


On Wednesday, April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote:

Hello all,
I use Windows 10 based laptop for my development. By default,
web2py serves its content via the rocket server.
My application makes use of the 'default' redis client () to
connect to the local redis server.
I started noticing a stacktrace, in the cmd prompt, from within
which web2py has started:
|
CreatedbyMassimoDiPierro,Copyright2007-2016
Version2.14.3-stable+timestamp.2016.03.26.17.54.43
Databasedrivers
available:psycopg2,pymysql,imaplib,sqlite3,pg8000,pyodbc,mysqlconnector
please visit:
http://127.0.0.1:8000/ 
starting browser...
please visit:
http://127.0.0.1:8000/ 
starting browser...
2016-04-2020:26:54,003-Rocket.Errors.Port8000-ERROR
-Traceback(most recent call last):
File"d:\code\git\web2py\gluon\rocket.py",line 587,inlisten
sock,addr =self.listener.accept()
File"D:\programs\open\python27\lib\site-packages\gevent\socket.py",line
316,inaccept
self._wait(self._read_event)
File"D:\programs\open\python27\lib\site-packages\gevent\socket.py",line
300,in_wait
self.hub.wait(watcher)
File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
348,inwait
result =waiter.get()
File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
575,inget
returnself.hub.switch()
File"D:\programs\open\python27\lib\site-packages\gevent\hub.py",line
338,inswitch
returngreenlet.switch(self)
LoopExit:Thisoperation would block forever
|

The error in the error-ticket is:
|
This operation would block forever
Version
web2py™ Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
Python Python 2.7.10: D:\programs\open\python27\python.exe
(prefix: D:\programs\open\python27)
Traceback


Traceback (most recent call last):
  File "d:\code\git\web2py\gluon\restricted.py", line 227, in
restricted
exec ccode in environment
  File
"d:/code/git/web2py/applications/myapp/controllers/myservice.py",
line 99, in 
  File "d:\code\git\web2py\gluon\globals.py", line 417, in 
self._caller = lambda f: f()
  File "d:\code\git\web2py\gluon\cache.py", line 661, in wrapped_f
rtn = func()
  File
"d:/code/git/web2py/applications/myapp/controllers/myservice.py",
line 68, in data
data = api.get_data(url)
  File "applications\myapp\modules\data\api.py", line 145, in get_data
return _get_data_for(url) if url else None
  File "applications\myapp\modules\data\api.py", line 164, in
_get_data_for
force_reload=rebuild
  File "applications\myapp\modules\myapp_constants.py", line 460,
in get_from_cache
cache_value = redis_cache.get(key)
  File
"D:\programs\open\python27\lib\site-packages\redis\client.py",
line 880, in get
return self.execute_command('GET', name)
  File
"D:\programs\open\python27\lib\site-packages\redis\client.py",
line 573, in execute_command
return self.parse_response(connection, command_name, **options)
  File
"D:\programs\open\python27\lib\site-packages\redis\client.py",
line 585, in parse_response
response = connection.read_response()
  File
"D:\programs\open\python27\lib\site-packages\redis\connection.py",
line 577, in read_response
response = self._parser.read_response()
  File
"D:\programs\open\python27\lib\site-packages\redis\connection.py",
line 238, in read_response
response = self._buffer.readline()
  File
"D:\programs\open\python27\lib\site-packages\redis\connection.py",
line 168, in readline
self._read_from_socket()
  File
"D:\programs\open\python27\lib\site-packages\redis\connection.py",
line 126, in _read_from_socket
data = self._sock.recv(socket_read_size)
  File

[web2py] Re: Nginx, uwsgi, on Windows

2016-04-20 Thread Niphlod
forget about uwsgi on windows. never really landed as production-ready. 
fortunately iis can run python without any hiccup and it's the current 
recommended way to deploy web2py in production on windows.

that being said, I'm really eager to know how the hell you're getting 
gevent mixed up with web2py's internal webserver, which is not at all 
compatible with gevent.

On Wednesday, April 20, 2016 at 7:21:09 PM UTC+2, Kiran Subbaraman wrote:
>
> Hello all,
> I use Windows 10 based laptop for my development. By default, web2py 
> serves its content via the rocket server. 
> My application makes use of the 'default' redis client () to connect to 
> the local redis server.
> I started noticing a stacktrace, in the cmd prompt, from within which 
> web2py has started:
> Created by Massimo Di Pierro, Copyright 2007-2016
> Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
> Database drivers available: psycopg2, pymysql, imaplib, sqlite3, pg8000, 
> pyodbc, mysqlconnector
> please visit:
> http://127.0.0.1:8000/
> starting browser...
> please visit:
> http://127.0.0.1:8000/
> starting browser...
> 2016-04-20 20:26:54,003 - Rocket.Errors.Port8000 - ERROR - Traceback (most 
> recent call last):
>   File "d:\code\git\web2py\gluon\rocket.py", line 587, in listen
> sock, addr = self.listener.accept()
>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
> line 316, in accept
> self._wait(self._read_event)
>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
> line 300, in _wait
> self.hub.wait(watcher)
>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
> 348, in wait
> result = waiter.get()
>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
> 575, in get
> return self.hub.switch()
>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
> 338, in switch
> return greenlet.switch(self)
> LoopExit: This operation would block forever
>
> The error in the error-ticket is:
>  This operation would block forever
> Version
> web2py™ Version 2.14.3-stable+timestamp.2016.03.26.17.54.43
> Python Python 2.7.10: D:\programs\open\python27\python.exe (prefix: 
> D:\programs\open\python27)
> Traceback
>
>
> Traceback (most recent call last):
>   File "d:\code\git\web2py\gluon\restricted.py", line 227, in restricted
> exec ccode in environment
>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
> line 99, in 
>   File "d:\code\git\web2py\gluon\globals.py", line 417, in 
> self._caller = lambda f: f()
>   File "d:\code\git\web2py\gluon\cache.py", line 661, in wrapped_f
> rtn = func()
>   File "d:/code/git/web2py/applications/myapp/controllers/myservice.py", 
> line 68, in data
> data = api.get_data(url)
>   File "applications\myapp\modules\data\api.py", line 145, in get_data
> return _get_data_for(url) if url else None
>   File "applications\myapp\modules\data\api.py", line 164, in _get_data_for
> force_reload=rebuild
>   File "applications\myapp\modules\myapp_constants.py", line 460, in 
> get_from_cache
> cache_value = redis_cache.get(key)
>   File "D:\programs\open\python27\lib\site-packages\redis\client.py", line 
> 880, in get
> return self.execute_command('GET', name)
>   File "D:\programs\open\python27\lib\site-packages\redis\client.py", line 
> 573, in execute_command
> return self.parse_response(connection, command_name, **options)
>   File "D:\programs\open\python27\lib\site-packages\redis\client.py", line 
> 585, in parse_response
> response = connection.read_response()
>   File "D:\programs\open\python27\lib\site-packages\redis\connection.py", 
> line 577, in read_response
> response = self._parser.read_response()
>   File "D:\programs\open\python27\lib\site-packages\redis\connection.py", 
> line 238, in read_response
> response = self._buffer.readline()
>   File "D:\programs\open\python27\lib\site-packages\redis\connection.py", 
> line 168, in readline
> self._read_from_socket()
>   File "D:\programs\open\python27\lib\site-packages\redis\connection.py", 
> line 126, in _read_from_socket
> data = self._sock.recv(socket_read_size)
>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
> line 394, in recv
> self._wait(self._read_event)
>   File "D:\programs\open\python27\lib\site-packages\gevent\socket.py", 
> line 300, in _wait
> self.hub.wait(watcher)
>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
> 348, in wait
> result = waiter.get()
>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
> 575, in get
> return self.hub.switch()
>   File "D:\programs\open\python27\lib\site-packages\gevent\hub.py", line 
> 338, in switch
> return greenlet.switch(self)
> LoopExit: This operation would block forever
>
> I do not see this issue on my ubuntu linux deployment.
>
> I suspected, without any evidence, that it