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 8272377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:06:35+00:00 2026-06-08T07:06:35+00:00

This is my render_GET function in class inherited from resource.Resource in twisted HTTP server:

  • 0

This is my render_GET function in class inherited from resource.Resource in twisted HTTP server:

    def render_GET(self, request):
           file = request.args['file'][0]
           altitude, azimuth, distance = request.args['position'][0].split(",")
           self.update_render(file, altitude, azimuth, distance, request.args['clientID'][0])
           # update_render() starts a thread that contacts this server again and POSTs data once done
           self.add_client(request.args['clientID'][0])

           while not self.client_data[request.args['clientID'][0]]:
                 # I GET STUCK HERE - the thread CANT send data to this dict since server is locked in this loop
                 time.sleep(0.5)

           return "DONE"

What happens is that I need the twisted server to wait until function update_render does something (this function is asynchronous, so by calling self.update_render() I just start it, not sure when the actual data is written. The return data of update_render() is written in self.client_data dict.

I need to detect the content of this dict in a loop BUT I am stuck there – it seems the server is locked in this loop BUT I need it to respond to other clients (they asynchronously fill self.client_data)

  • 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-08T07:06:37+00:00Added an answer on June 8, 2026 at 7:06 am

    You never want to write a while loop like that in a Twisted-using application.

    Ideally, you want a better API than update_render – one that returns a Deferred. A Deferred gives you a uniform, composable, convenient API for managing callbacks. Callbacks are fairly central to programming with Twisted.

    update_render should use the Deferred‘s callback method once it gets the client data – instead of putting it into self.client_data. By using the Deferred, it plays nicely in the event-driven system of Twisted. A callback you (the caller) attach to the Deferred can send the result to the client.

    Twisted Web has a slight quirk in that you’ll need to return twisted.web.server.NOT_DONE_YET from the render_GET method to let the server know that the response is forthcoming.

    Have a look at Twisted Web In 60 Seconds for some examples of asynchronously generating responses.

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

Sidebar

Related Questions

Is that possible to define a function without referencing to self this way? def
I have Login.php form like this: class Form_Login extends Zend_Form { public function init()
I wrote this little function for writing out HTML tags: def html_tag(tag, content=None, close=True,
Handler Implementation class TestHandler(RequestHandler, Jinja2Mixin): def get(self): channel_id = str(random.randint(1, 10000)) + str(datetime.now()) chat_token
I wrote this function to get the unread count of google reader items. function
I'm using this code to render an image from view. Then i am saving
Why does this graphml file below does not render the node color properly in
How would I do this (C#) in F# public class MyClass { void Render(TextWriter
I'm using this coffeescript code: in a spec file: index = new MeetingIndex(render: false,
This is an annoying problem I am having with Twisted.web. Basically, I have a

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.