unicode-to-ascii: replace with space, not "?"
Hello, I've been using "data.encode('ascii','replace')" to force an ASCII string out of Unicode data, with "?" in the place of non-ASCII letters. However, now I want to use a blank space (or maybe a dash) instead of a question mark. How do I do this? Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
Re: multiproccess: What is the Dameon flag?
> > > > What is the Daemon flag and when/why would I want to use it? > > > From the documentation: "When a process exits, it attempts to terminate > all of its daemonic child processes.". > > Sometimes you want the main process to wait for its worker processes to > terminate before terminating itself so that you can be sure that > everything (including resources they might use) has been tidied up. > Other times there's nothing to tidy up so you just want the worker > processes to terminate when the main process terminates. In the second > case the worker process are known as daemon processes. Thank you. Two clarification questions: 1) So, without that flag the parent process could finish before the kids, and the kids would keep running? 2) If you use kid.join() in parent, the parent will always wait for kid to finish before continuing? (And eventually quitting) Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
multiproccess: What is the Dameon flag?
Hello, What is the Daemon flag and when/why would I want to use it? Thank you, AF -- http://mail.python.org/mailman/listinfo/python-list
Scheduling algorithm: Suggestions?
Hello, I have a batch of "rpc style" calls that I must make to an external server via HTTP in a multi threaded fashion. (Return vales must be saved.) Problem is, I need to throttle the rate at which I do this. Each HTTP call takes between 0.2 and several seconds to complete. I need to control two different aspects: 1) Number of new connections per second. 2) Total number of parallel connections allowed. Additionally, it is possible that an HTTP call could result in an error at the remote server. If so, it must be retried couple of times before an error is logged. Does anybody have a suggestions as to the correct way to implement such a system in Python? Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing: Correct usage of pool & queue?
Hello, I have a list of tasks/items that I want handed off to threads/processes to complete. (I would like to stick with process if I could, since there is some CPU work here. ) Each task involves some calculations and a call to a remote server over urllib2/HTTP. The time to complete each task varies from 1 to 20 seconds depending on a number of factors including variable delay on the remote server. I would like to: 1) Have a maximum of 20 "in-flight" tasks. (thus worker processes?) 2) Not overload the external server that each task is calling. No more than "3 new tasks" per second. More "waiting" tasks may be OK, i need to test it. 3) Certain tasks in my list must be processed in the correct order. (I guess the asignment logic must somehow tag those to by done by the same worker?) Do any of you have suggestions? Can someone point me in the direction of sample code for this? Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
Re: XML(JSON?)-over-HTTP: How to define API?
> I have an (in-development) python system that needs to shuttle events / > requests > around over the network to other parts of itself. It will also need to > cooperate with a .net application running on yet a different machine. > > So, naturally I figured some sort of HTTP event / RPC type of would be a good > idea? > > Are there any modules I should know about, or guidelines I could read, that > could aid me in the design of the API? > > To clarify: Each message would be <1KB of data total, and consist of some structured object containing strings, numbers, dates, etc. For instance there would be an "add user" request that would contain one or more User objects each having a number of properties like: - Full Name - Username - Password - Email addresses (a variable length array) - Street Address line1 - Street Address line1 - Street Address line1 - City - State - Zip - Sign Up Date and so on. Since I need to work with other platforms, pickle is out... what are the alternatives? XML? JSON? How should I formally define each of the valid messages and objects? Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
XML(JSON?)-over-HTTP: How to define API?
I have an (in-development) python system that needs to shuttle events / requests around over the network to other parts of itself. It will also need to cooperate with a .net application running on yet a different machine. So, naturally I figured some sort of HTTP event / RPC type of would be a good idea? Are there any modules I should know about, or guidelines I could read, that could aid me in the design of the API? Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Project source code layout?
> > I was hoping to keep the dev layout as close to deployment possible. > > Completely different purposes. For example, the actual production database > and config files form no part of your development project, do they? And > conversely, utility scripts that might be used, for example, to set up a > database, should not be part of the production installation. > The data will certainly be different. Good point. (Though for now even the production DB will be sqlite.) > Here's one layout I used in a production system for an online shop: > > /home/shop/bin -- binaries (CGI and daemon) > /home/shop/lib -- common libraries for binaries > /home/shop/config -- configuration files, incl format templates > /home/shop/state -- socket for interprocess communication, log files > > Thank you. Couple of questions: 1) Do you use virtualpython? 2) How do you load the modules in your lib directory? 3) How do you reference your configuration directives from within your modules and CGI/daemon scripts? Thank you, Allen -- http://mail.python.org/mailman/listinfo/python-list
Re: Project source code layout?
> > I'm new to Python, and am looking for some suggestions as to the source > > code layout for a new project. > > Is this the development layout or the deployment layout? The two need not > bear any resemblance. > Looking for suggestions on both. I was hoping to keep the dev layout as close to deployment possible. Thank you, :) -- http://mail.python.org/mailman/listinfo/python-list
Project source code layout?
Hello, I'm new to Python, and am looking for some suggestions as to the source code layout for a new project. The project will be a tg/pylons daemon, a static website, and a collection of other scripts that will interact with the app and DB. Here is what I am thinking so far: root_folder/ - app/ -- Code for pylons/TG web app - web/ -- Public static web files (and wsgi / fastCGI connector files) - db/ -- SQlite DB - scripts/ -- Various custom programs that will also interact with the DB / app. (Some cron, some interactive.) - config/ -- 3-rd party API tokens, DB parameters, etc. However, I am still wondering about a few items: 1) Where to create the virtualpython installation that will be used by both the app and the scripts. 2) Where to put our in-house created python modules so that they can be imported by both the TG app and our own scripts. 3) How to cleanly provide the various config settings to both the web app and scripts. Any suggestions? ideas? fwiw, I am planing on keeping the whole thing in a Mercurial repository. Thank you, Allen :) -- http://mail.python.org/mailman/listinfo/python-list