Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:23:38+00:00 2026-06-03T21:23:38+00:00

My stack is the uWSGI 1.2.2, bottle, and gevent 1.0b2. I am trying to

  • 0

My stack is the uWSGI 1.2.2, bottle, and gevent 1.0b2. I am trying to do the following async.

1) serve a pixel image as fast as possible and close the connection
2) I then pass the query string to a function so I can use gevent to async write data to redis
3) Per the uwsgi doc at http://projects.unbit.it/uwsgi/wiki/Gevent I appear to doing it correct.
4) In the logs i get this error. I servers the pixel but…..

Traceback (most recent call last):
  File "/home/ubuntu/workspace/bottleServer.py", line 222, in upixel
    gevent.spawn(pixelRedisWrite,cookie_id,query_string,yield_time)
UnboundLocalError: local variable 'query_string' referenced before assignment
[pid: 28173|app: 0|req: 91/91] 120.28.191.173 () {40 vars in 1909 bytes} [Sat May 12 19:07:24 2012] GET /upixel?bid=eydhdmlkJzogJ2luZm9AYWRtYWdpYy5jby5qcCcsICdjcmlkJzogJzIwNzY3MDczNTE1JywgJ21hYm

So….why is this happening? The query string is there….

Here is how I launch uwsgi

sudo /usr/local/bin/uwsgi --loop gevent --socket :3031 --wsgi-file /home/ubuntu/workspace/bottleServer.py --master --async 10 --listen 100 --processes 1 





def pixelRedisWrite(ckid,qs,yield_time):
    pass


@route('/upixel/')
@route('/upixel')
def upixel():
    sw = stopwatch.Timer()

    if request.get_cookie('rtbhui'):
        cookie_id = request.get_cookie('rtbhui')
    else:
        cookie_id=str(uuid4())
        response.set_cookie('rtbhui', cookie_id , max_age=31556952*2, domain='rtb.rtbhui.com')

    cookie_id='test'
    response.content_type = 'image/gif'
    sw.stop()
    yield_time = int(sw.elapsed * 1000)
    if request.query.bid:
        query_string = base64.b64decode(request.query.bid)
        query_string = ast.literal_eval(query_string)
        #pixelRedisWrite(cookie_id,query_string,yield_time)
    yield pixel
    #print 'gggggg',query_string
    gevent.spawn(pixelRedisWrite,cookie_id,query_string,yield_time)


if __name__ == "__main__":
    # Interactive mode
    run(host='localhost', port=8080)
else:
    # Mod WSGI launch
    os.chdir(os.path.dirname(__file__))
    application = default_app()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:23:39+00:00Added an answer on June 3, 2026 at 9:23 pm

    This has nothing to do with gevent or uwsgi. You’re defining query_string only in certain case (when request.query.bid is true). If it’s not true, the variable is undefined and UnboundLocalError tells you that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to deploy Django to Heroku (cedar stack) with uwsgi as my app
Stack: I'm trying to turn my website's user profile into more of a feed
Greetings Stack Overflow community. I'm trying to make a function that can pop all
I stack with this, I'm trying to create application using TabLayout. I have 3
Stack Overflowers: I have been racking my brain trying to get an List(of T)
The following would cause stack overflow for large 'n', and I can understand why.
I'm deploying my django app with nginx-uwsgi I wanna add Varnish to this stack.
Hail Stack! I'm having a hard time trying to figure out why my treeview
Stack is warning me this is a subjective question, and will likely be close,
Hello Stack Overflow Experts, i have need of your expertice: I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.