Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Unexpected timeous using haigha/gevent in uwsgi server
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
vitaly  
View profile  
 More options Aug 18 2012, 2:53 am
From: vitaly <vitaly.krugl.nume...@gmail.com>
Date: Fri, 17 Aug 2012 23:53:16 -0700 (PDT)
Local: Sat, Aug 18 2012 2:53 am
Subject: Unexpected timeous using haigha/gevent in uwsgi server

Python 2.6.7
gevent 1.0b2
haigha v0.4.1
uwsgi server v1.2.5

nginx routing to uwsgi server via uwsgi protocol.

During handling of an request, the python handler (invoked from uwsgi
worker subprocess) makes use of the haigha AMQP client library with its
GeventTransport to send message and wait for responses via RabbitMQ broker.
 Each transaction entails connecting to RabbitMQ broker, sending a single
request message via Haigha, waiting for a single response message, then
tearing down the RabbitMQ connection.

Usually one or two such transactions succeed, but then all subsequent
requests time out while waiting for the response message.  The handler uses
"with gevent.Timeout(seconds=timeoutSec):" to implement the timeout.

The exact same python code works perfectly when executed outside of uwsgi
server, even when many such transactions are executed concurrently using
gevent Greenlets.  I've done plenty of testing without any failures at all
to be pretty certain that this haigha-based code works reliably *outside*
the uwsgi environment.  The problems occur only when executing the exact
same coe in the uwsgi environment.

When Haigha receives a message, a Haigha callback (running in another
Greenlet) deposits the message in a gevent Queue.  The handler waits on
this gevent Queue.  When gevent.Timeout() expires, the traceback looks like
this:
  File "/Users/current/lib/python2.6/site-packages/gevent/queue.py", line
189, in get
    result = waiter.get()
  File "/Users/current/lib/python2.6/site-packages/gevent/hub.py", line
616, in get
    return self.hub.switch()
  File "/Users/current/lib/python2.6/site-packages/gevent/hub.py", line
373, in switch
    return greenlet.switch(self)
Timeout: 30 seconds

uwsgi server is started as follows:

/bin/uwsgi \

  -s 127.0.0.1:19001 \

  -d path-to-log-file.log \

  -M \

  --pidfile pid-file-path.pid \

  --vacuum \

  --idle 300 \

  -p 1 \

  --pythonpath api-server-home-path \

  --pythonpath /home/user/current/lib/python2.6/site-packages \

  --pythonpath /usr/lib/python2.6/site-packages \

  --chdir server-home-dir-path \

  --env MYAPP_CONFIG_FILE=$MYAPP_CONFIG_FILE \

  --module myapp.webapi

Please help.

Thank you,

Vitaly


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roberto De Ioris  
View profile   Translate to Translated (View Original)
 More options Aug 18 2012, 3:33 am
From: "Roberto De Ioris" <robe...@unbit.it>
Date: Sat, 18 Aug 2012 09:33:01 +0200
Local: Sat, Aug 18 2012 3:33 am
Subject: Re: [gevent] Unexpected timeous using haigha/gevent in uwsgi server

I have never used haigha, but the only thing popping in my mind is not
taking in account uWSGI fork() usage. If you create a Queue in
myapp.webappi module (so in the master), it will not be usable by the
workers. Try adding --lazy, if it works i suggest you to upgrade to uWSGI
1.3 and use --lazy-apps (load apps like in lazy mode but maintains the
non-lazy behaviour for all of the other uWSGI parts)

--
Roberto De Ioris
http://unbit.it


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vitaly  
View profile  
 More options Aug 18 2012, 4:18 am
From: vitaly <vitaly.krugl.nume...@gmail.com>
Date: Sat, 18 Aug 2012 01:18:34 -0700 (PDT)
Local: Sat, Aug 18 2012 4:18 am
Subject: Re: [gevent] Unexpected timeous using haigha/gevent in uwsgi server

On Saturday, August 18, 2012 12:33:01 AM UTC-7, Roberto De Ioris wrote:

> I have never used haigha, but the only thing popping in my mind is not
> taking in account uWSGI fork() usage. If you create a Queue in
> myapp.webappi module (so in the master), it will not be usable by the
> workers. Try adding --lazy, if it works i suggest you to upgrade to uWSGI
> 1.3 and use --lazy-apps (load apps like in lazy mode but maintains the
> non-lazy behaviour for all of the other uWSGI parts)

> --
> Roberto De Ioris
> http://unbit.it

Hi Roberto,

thank you for the quick follow-up.  I forgot to mention that we already
tried the --lazy option, but still had the same problem.  Based on your
description on http://projects.unbit.it/uwsgi/wiki/ThingsToKnow, I expected
that --lazy would solve this problem, but unfortunately it did not. It's a
complete mystery -- the code runs fine outside of uwsgi, but fails very
easily in the uwsgi environment.  Does uwsgi server patch any python
built-in APIs? (socket, etc.)

Thank you,
Vitaly


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roberto De Ioris  
View profile  
 More options Aug 18 2012, 12:19 pm
From: "Roberto De Ioris" <robe...@unbit.it>
Date: Sat, 18 Aug 2012 18:19:16 +0200
Local: Sat, Aug 18 2012 12:19 pm
Subject: Re: [gevent] Unexpected timeous using haigha/gevent in uwsgi server

Can you write a tiny test-script to allow me to reproduce the problem ?

Have you tried with uWSGI 1.3 (there are a bunch of optimizations
gevent-related, maybe it contains some fix i forgot to backport...) ?

--
Roberto De Ioris
http://unbit.it


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vitaly  
View profile  
 More options Aug 18 2012, 9:37 pm
From: vitaly <vitaly.krugl.nume...@gmail.com>
Date: Sat, 18 Aug 2012 18:37:23 -0700 (PDT)
Local: Sat, Aug 18 2012 9:37 pm
Subject: Re: [gevent] Unexpected timeous using haigha/gevent in uwsgi server

On Saturday, August 18, 2012 9:19:16 AM UTC-7, Roberto De Ioris wrote:

> Can you write a tiny test-script to allow me to reproduce the problem ?

> Have you tried with uWSGI 1.3 (there are a bunch of optimizations
> gevent-related, maybe it contains some fix i forgot to backport...) ?

> --
> Roberto De Ioris
> http://unbit.it

Hi Roberto, I haven't tried uWSGI 1.3.  I could a small program to
reproduce this, but it would involve calls into the Haigha library.  Is
that okay?  I will take a fresh look at this when I return from vacation a
week from now.

Best,
Vitaly


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vitaly  
View profile  
 More options Aug 29 2012, 5:50 pm
From: vitaly <vitaly.krugl.nume...@gmail.com>
Date: Wed, 29 Aug 2012 14:50:17 -0700 (PDT)
Local: Wed, Aug 29 2012 5:50 pm
Subject: Re: [gevent] Unexpected timeous using haigha/gevent in uwsgi server

I did more debugging yesterday and finally nailed it down -- it's nothing
to do with uWSGI; it was an internal error.  Sorry for the trouble and
thank you for all the help.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »