Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've seen several examples of simple Python client/server programs on the web. My question is, in order to have the server consistently listening from sunrise to sunset, what is the most efficient way to go?
If I just include an infinite while loop for accepting connections, is that the best way to utilize my resources, or is there a better/more efficient way to program that?
In other words, is the server tutorial here best practice (minus not catching exceptions)?
The best course of action for you would be to explore the tulip library. It's already checked in in the upcoming Python 3.4 (named asyncio), but you can start using it today.
Tulip library on google code: https://code.google.com/p/tulip/source/checkout
PEP 3156 Asynchronous IO Support Rebooted: the "asyncio" Module: http://www.python.org/dev/peps/pep-3156/
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 months ago.
Improve this question
I started learning web development, so besides Frontend, which is what I'm learning now, I want to learn a backend language (Python or PHP).
Let's suppose I start learning Python ( or the other way around), but a company that uses PHP for backend hired me.
Is it possible to get along with what I have, or will I have to learn PHP?
Thank you.
Yes, it should work, but remember, treating them as two separate languages because they are PHP and Python, the best approach is to ignore their specificity.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a working R script. Can this be wrapped in a Python code so it can be deployed as an API ?
As mentioned in an earlier post, things that are not easy in R can be relatively simple in other languages. Another example would be connecting to Amazon Web Services. In relation to s3, although there are a number of existing packages, many of them seem to be deprecated, premature or platform-dependent. (I consider the cloudyr project looks promising though.)
If there isn’t a comprehensive R-way of doing something yet, it may be necessary to create it from scratch. Actually there are some options to do so by using AWS Command Line Interface, AWS REST API or wrapping functionality of another language.
http://jaehyeon-kim.github.io/2015/11/Quick-Test-to-Wrap-Python-in-R.html
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Today I want to program a karaoke in python.
I have to show a text (the lyrics of the song) scroll down and play the music in the background.
But I'm wondering if I have to do some code to move the lyrics and another code to play the music or I have to join both codes to do the parallel programming
But I know that Python is a structured language and I can not do parallel programming.
There are basically two simple ways to do concurrent programming in Python, using build-in libraries:
Using the threading module (https://docs.python.org/3/library/threading.html)
Using the multiprocessing module (https://docs.python.org/3/library/multiprocessing.html)
Yes, check Parallel Processing, where you can find information for:
Symmetric Multiprocessing
Cluster Computing
Cloud Computing
Grid Computing
and pick what best fits your application.
Or, check How to do parallel programming in Python?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I was wondering if there is a proper way to periodically check an api for updated data. I'm looking for a more efficient solution than a while loop with a delay timer.
Are there any standard headers that can be checked to see if content was updated (in order to skip comparing previous results to the new ones?)
Additional notes
I using python at the moment but this is a broad question regarding all programming languages.
You probably want to look at the Conditional Requests spec and the Caching spec.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to write my own protocol so that multiple servers can pass data and connect with each other, kind of like mongo://. I have been looking at TCP & I understand ports, but how do I write something so that people can just do something like connect("proto://example.com:6767/") ?
Also, I'm writing in python.
Thanks!
I believe you need to look into urllib2 and writing a subclass of BaseHandler, specifically the functions protocol_request and protocol_response.
Whether the way urllib2 handles request/response cycles suits your application is up to you to decide -- it may or may not be exactly what you want.