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

  • Home
  • SEARCH
  • 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 8891313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:42:36+00:00 2026-06-14T22:42:36+00:00

I have a service provided by a REST API, with a Python library wrapping

  • 0

I have a service provided by a REST API, with a Python library wrapping it using python-requests.

I have a ‘dumb’ user interface designed by a third party (not Python) to connect to a local XML-RPC.

Now I have to connect both ends and forward the XML-RPC calls to the REST API and return the results. It’s mostly asynchronous and doesn’t depend on results returning to the user in real-time. Most of the XML-RPC calls are supposed to return immediately, queue a task, and some other call will query the results later. Data is stored in an sqlite database until needed.

So, I decided to use twisted.web.xmlrpc for this middle layer and use the requests based lib for the remote calls and it works fine. I guess I’m blocking twisted’s mainloop for a few seconds once in a while, but that’s not a big deal.

The problem is that I also have to make some big file uploads from this middle layer to the HTTP server providing the REST API. I can’t make those uploads using the requests based lib because it will block the twisted loop until the upload is finished.

I’d rather not use multithreading, and I really don’t want to rewrite the python-requests based lib I have as a twisted client. Is there any way I can integrate requests into twisted’s mainloop, or any other reasonable solution?

  • 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-14T22:42:37+00:00Added an answer on June 14, 2026 at 10:42 pm

    If you like requests’ style of API, but want something that would work with Twisted, consider using treq. There are support libraries for writing interfaces which can be either synchronous or asynchronous depending on their caller’s needs.

    If you really want to use requests, but you don’t want to block the main loop, you can invoke it with twisted.internet.threads.deferToThread. This is mostly transparent, and if your requests don’t share any state you can almost ignore the fact that you’re using multithreading.

    But, ultimately, Jean-Paul’s comment is correct; you are going to need to make some changes to the way this code works, if you want to change the way it works.

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

Sidebar

Related Questions

I need to create a deployment using REST API. http://msdn.microsoft.com/en-us/library/windowsazure/ee460813 There I have to
I am writing a REST API for a service that will accept user contributed
When using the REST interface for Last.fm web service, are the Etag and/or Last-Modified
Using JDeveloper as my IDE, I have a web application which calls services provided
I have the following bean defined: <sec:authentication-manager alias=authenticationManager> <sec:authentication-provider user-service-ref=userDetailsService /> </sec:authentication-manager> I guess
We are building a REST API using ASP.NET MVC. This API is similar in
I'm trying to implement REST API using Jersey with Spring on Tomcat but I'm
I have been exploring OAuth version 1.0 for the REST API I am currently
Possible Duplicate: SQL Query with MySQL I implement a Rest Web Service (JAX-RS) using
I am currently writing a rest API in python with the microframework Flask. It's

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.