Re: "High water" Memory fragmentation still a thing?

2014-10-08 Thread bryanjugglercryptographer
Chris Angelico wrote: > Sure, and that's all well and good. But what I just cited there *is* a > shipping product. That's a live server that runs a game that I'm admin > of. So it's possible to do without the resource safety net of periodic > restarts. Nice that the non-Python server you administe

Re: "High water" Memory fragmentation still a thing?

2014-10-06 Thread bryanjugglercryptographer
dieter wrote: > As you see from the description, memory compaction presents a heavy burden > for all extension writers. Particularly because many CPython extensions are actually interfaces to pre-existing libraries. To leverage the system's facilities CPython has to follow the system's conventio

Re: "High water" Memory fragmentation still a thing?

2014-10-06 Thread bryanjugglercryptographer
Chris Angelico wrote: > This is why a lot of long-duration processes are built to be restarted > periodically. It's not strictly necessary, but it can be the most > effective way of solving a problem. I tend to ignore that, though, and > let my processes just keep on running... for 88 wk 4d 23:56:2

Re: Best python web framework to build university/academic website

2013-07-30 Thread bryanjugglercryptographer
b.kris...@gmail.com wrote: > I got a chance to build an university website, within very short period of > time. > I know web2py, little bit of Django, so please suggest me the best to build > rapidly. Web2py rocks like nothing else for getting up fast. If you already know it, problem solved.

Re: Prime number generator

2013-07-30 Thread bryanjugglercryptographer
Chris Angelico wrote: > Bas wrote: > > Still trying to figure out your algorithm ... > > It's pretty simple. (That's a bad start, I know!) Like the Sieve of > Eratosthenes, it locates prime numbers, then deems every multiple of > them to be composite. Unlike the classic sieve, it does the "deem" >

Re: Memory usage per top 10x usage per heapy

2012-09-27 Thread bryanjugglercryptographer
MrsEntity wrote: > Based on heapy, a db based solution would be serious overkill. I've embraced overkill and my life is better for it. Don't confuse overkill with cost. Overkill is your friend. The facts of the case: You need to save some derived strings for each of 2M input lines. Even half th

Re: How to send a var to stdin of an external software

2008-03-14 Thread bryanjugglercryptographer
I wrote: > And here's a thread example, based on Benjamin's code: [...] Doh! Race condition. Make that: import subprocess import thread import Queue def readtoq(pipe, q): q.put(pipe.read()) cat = subprocess.Popen('cat', shell=True, stdin=subprocess.PIPE, stdout=subpr

Re: How to send a var to stdin of an external software

2008-03-14 Thread bryanjugglercryptographer
Floris Bruynooghe wrote: > Benjamin Watine wrote: > > Could you give me more information / examples about the two solutions > > you've proposed (thread or asynchronous I/O) ? > > The source code of the subprocess module shows how to do it with > select IIRC. Look at the implementation of the commu

Re: subprocess.Popen pipeline bug?

2008-03-13 Thread bryanjugglercryptographer
Marko Rauhamaa wrote: > This tiny program hangs: > > > #!/usr/bin/env python > import subprocess > a = subprocess.Popen('cat',shell = True,stdin = subprocess.PIPE, > stdout = subprocess.PIPE) > b = subproc

Re: Saving parameters between Python applications?

2007-09-17 Thread bryanjugglercryptographer
On Sep 17, 6:39 am, Laurent Pointal > May use simple file in known place: > $HOME/.myprefs > $HOME/.conf/myprefs > > Or host specific configuration API: > WindowsRegistry HKEY_CURRENT_USER\Software\MySociety\MyApp\myprefs > > See os.getenv, and _winreg Windows specific module. > See also standard C

Re: BCD List to HEX List

2006-08-03 Thread bryanjugglercryptographer
ohn Machin wrote: > [EMAIL PROTECTED] wrote: > > "For each nibble n of x" means to take each 4 bit piece of the BCD > > integer as a value from zero to sixteen (though only 0 through 9 > > will appear), from most significant to least significant. > The OP's input, unvaryingly through the whole thre

Re: Windows vs. Linux

2006-08-02 Thread bryanjugglercryptographer
Sybren Stuvel wrote: > John Salerno enlightened us with: > > But of course I still agree with you that in either case it's not a > > judgment you can fairly make 30 years after the fact. > > I don't see Microsoft changing it the next 30 years either... Apple > moved from \r to \n as EOL character.

Re: BCD List to HEX List

2006-08-02 Thread bryanjugglercryptographer
John Machin wrote: > [EMAIL PROTECTED] wrote: > > "For each nibble n of x" means to take each 4 bit piece of the BCD > > integer as a value from zero to sixteen (though only 0 through 9 > > will appear), from most significant to least significant. > The OP's input, unvaryingly through the whole t

Re: BCD List to HEX List

2006-08-01 Thread bryanjugglercryptographer
John Machin wrote: > [EMAIL PROTECTED] wrote: > > >My version assumes three subroutines: extracting > > nibbles, shifting, and adding, Those are pretty simple, so I asked > > if he needed them rather than presenting them. > > Assuming we have > > them, the algorithm is three lines long. > > Perhap

Re: fast pythonic algorithm question

2006-08-01 Thread bryanjugglercryptographer
Guyon Morée wrote: > i have a big list of tuples like this: > > [ (host, port, protocol, startime, endtime), .. ] etc > > now i have another big(ger) list of tuples like this: > > [(src_host, src_port, dest_src, dest_port, protocol, time), ... ] etc > > now i need to find all the items in the seco

Re: BCD List to HEX List

2006-08-01 Thread bryanjugglercryptographer
John Machin wrote: > [EMAIL PROTECTED] wrote: > > John Machin wrote: > > > [EMAIL PROTECTED] wrote: > > > > To turn BCD x to binary integer y, > > > > > > > > set y to zero > > > > for each nibble n of x: > > > > y = (((y shifted left 2) + y) shifted left 1) + n > > > > > > Yeah yeah yeah

Re: Using Python for my web site

2006-08-01 Thread bryanjugglercryptographer
northband wrote: > Hi, I am interested in re-writing my website in Python vs PHP but have > a few questions. Here are my specs, please advise as to which > configuration would be best: > > 1.Dell Poweredge Server, w/IIS, currently Windows but considering > FreeBSD > 2. Site consists of result page

Re: BCD List to HEX List

2006-07-31 Thread bryanjugglercryptographer
John Machin wrote: > [EMAIL PROTECTED] wrote: > > Philippe Martin wrote: > > > Yes, I came here for the "algorithm" question, not the code result. > > > > To turn BCD x to binary integer y, > > > > set y to zero > > for each nibble n of x: > > y = (((y shifted left 2) + y) shifted left 1)

Re: BCD List to HEX List

2006-07-31 Thread bryanjugglercryptographer
Philippe Martin wrote: > Yes, I came here for the "algorithm" question, not the code result. To turn BCD x to binary integer y, set y to zero for each nibble n of x: y = (((y shifted left 2) + y) shifted left 1) + n Do you need instruction on extracting nibbles, and shifting and adding

Re: how to make python socket server work with the app.MainLoop() in wxpython?

2006-07-30 Thread bryanjugglercryptographer
Philippe Martin wrote: > Philippe Martin wrote: > > You need to have you server in a separate thread. > PS: > > http://wiki.wxpython.org/index.cgi/LongRunningTasks And here's an important bit from the wxWindows doc: For communication between secondary threads and the main thread, you may us

Re: Client/Server Question

2006-07-29 Thread bryanjugglercryptographer
[EMAIL PROTECTED] wrote: > My server.py looks like this > > -CODE-- > #!/usr/bin/env python > import socket > import sys > import os > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > host = '' > port = 2000 > > s

Re: Threads vs Processes

2006-07-28 Thread bryanjugglercryptographer
sturlamolden wrote: > A noteable exception is a toy OS from a manufacturer in Redmond, > Washington. It does not do COW fork. It does not even fork. > > To make a server system scale well on Windows you need to use threads, > not processes. Here's one to think about: if you have a bunch of thread

Re: SocketServer and timers

2006-07-28 Thread bryanjugglercryptographer
Simon Forman wrote: > alf wrote: > > Hi, > > > > I have one thread app using SocketServer and use server_forever() as a > > main loop. All works fine, but now I need certain timer checking let's > > say every 1 second something and stopping the main loop. So questions are: > > -how to stop ser

Re: SocketServer and timers

2006-07-27 Thread bryanjugglercryptographer
alf wrote: > I have one thread app using SocketServer and use server_forever() as a > main loop. All works fine, but now I need certain timer checking let's > say every 1 second something and stopping the main loop. So questions are: > -how to stop serve_forever Override serve_forever() and

Re: How to force a thread to stop

2006-07-27 Thread bryanjugglercryptographer
Paul Rubin wrote: > Actually I don't understand the need for SSH. Who are you and what have you done with the real Paul Rubin? > This is traffic over a > LAN, right? Is all of the LAN traffic encrypted? That's unusual; SSH > is normally used to secure connections over the internet, but the > l

Re: Threads vs Processes

2006-07-27 Thread bryanjugglercryptographer
mark wrote: > The debate should not be about "threads vs processes", it should be > about "threads vs events". We are so lucky as to have both debates. > Dr. John Ousterhout (creator of Tcl, > Professor of Comp Sci at UC Berkeley, etc), started a famous debate > about this 10 years ago with the f

Re: Threads vs Processes

2006-07-27 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: [...] > I actually do use pickle (not for this, but for other things), could you > elaborate on the safety issue? >From http://docs.python.org/lib/node63.html : Warning: The pickle module is not intended to be secure against erroneous or maliciously constructed

Re: Threads vs Processes

2006-07-27 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: > Ah, alright, I think I understand, so threading works well for sharing > python objects. Would a scenario for this be something like a a job > queue (say Queue.Queue) for example. This is a situation in which each > process/thread needs access to the Queue to get the

Re: How to force a thread to stop

2006-07-27 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: > [EMAIL PROTECTED] wrote: > > Carl J. Van Arsdall wrote: > > > >> [EMAIL PROTECTED] wrote: > >> > >>> Carl J. Van Arsdall wrote: > >>> > >>> I don't get what threading and Twisted would to do for > >>> you. The problem you actually have is that you sometimes > >>> need

Re: How to force a thread to stop

2006-07-26 Thread bryanjugglercryptographer
Gerhard Fiedler wrote: > Carl J. Van Arsdall wrote: > > Well, I guess I'm thinking of an event driven mechanism, kinda like > > setting up signal handlers. I don't necessarily know how it works under > > the hood, but I don't poll for a signal. I setup a handler, when the > > signal comes, if it

Re: Threads vs Processes

2006-07-26 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: > Alright, based a on discussion on this mailing list, I've started to > wonder, why use threads vs processes. In many cases, you don't have a choice. If your Python program is to run other programs, the others get their own processes. There's no threads option on that.

Re: How to force a thread to stop

2006-07-26 Thread bryanjugglercryptographer
Paul Rubin wrote: > Have you looked at POSH yet? http://poshmodule.sf.net Paul, have you used POSH? Does it work well? Any major gotchas? I looked at the paper... well, not all 200+ pages, but I checked how they handle a couple parts that I thought hard and they seem to have good ideas. I didn

Re: why is this not working? (nested scope question)

2006-07-26 Thread bryanjugglercryptographer
[EMAIL PROTECTED] wrote: [...] > def f1() : > x=88 > f2() > def f2() : > print 'x=',x > f1() > > that returns an error saying that "NameError: global name 'x' is not > defined". I expected f2 to "see" the value of x defined in f1 since it > is nested at runtime. Ah, no, Python uses "s

Re: How to force a thread to stop

2006-07-26 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: > [EMAIL PROTECTED] wrote: > > Carl J. Van Arsdall wrote: > > > > I don't get what threading and Twisted would to do for > > you. The problem you actually have is that you sometimes > > need terminate these other process running other programs. > > Use spawn, fork/exec*

Re: How to force a thread to stop

2006-07-25 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: > Unfortunately this is due to the nature of the problem I am tasked with > solving. I have a large computing farm, these os.system calls are often > things like ssh that do work on locations remote from the initial python > task. I suppose eventually I'll end up using

Re: How to force a thread to stop

2006-07-25 Thread bryanjugglercryptographer
Dennis Lee Bieber wrote: > On Mon, 24 Jul 2006 10:27:08 -0700, "Carl J. Van Arsdall" > > My problem with the fact that python doesn't have some type of "thread > > killer" is that again, the only solution involves some type of polling > > loop. I.e. "if your thread of execution can be written so

Re: How to force a thread to stop

2006-07-25 Thread bryanjugglercryptographer
Carl J. Van Arsdall wrote: [...] > My problem with the fact that python doesn't have some type of "thread > killer" is that again, the only solution involves some type of polling > loop. A polliing loop is neither required nor helpful here. [...] > #Just pretend for the sake of arguement that 'o

Re: httplib, threading, wx app freezing after 4 hours

2006-07-23 Thread bryanjugglercryptographer
Mark rainess wrote: [...] > It runs perfectly for about 4 hours, then freezes. > I'm stuck. How do I debug this? [...] > Can anyone suggest techniques to help me learn what is going on. By inspection: "errcode" is undefined; I expect you stripped the example a bit too far. If it is set to somethi

Re: How to force a thread to stop

2006-07-22 Thread bryanjugglercryptographer
Hans wrote: > Hi all, > > Is there a way that the program that created and started a thread also stops > it. > (My usage is a time-out). > > E.g. > > thread = threading.Thread(target=Loop.testLoop) > thread.start() # This thread is expected to finish within a second > thread.join(2)# Or ti

Re: random shuffles

2006-07-21 Thread bryanjugglercryptographer
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. You would be mistaken (except

Re: how to know if socket is still connected

2006-07-19 Thread bryanjugglercryptographer
Grant Edwards wrote: > If the server has closed the connection, then a recv() on the > socket will return an empty string "", after returning all the data the remote side had sent, of course. > and a send() on the > socket will raise an exception. Send() might, and in many cases should, raise a

Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread bryanjugglercryptographer
I wrote: > I prefer the tread solution. You can see my exmaple > in message <[EMAIL PROTECTED]>. > >http://groups.google.com/group/comp.lang.python/msg/ffd0159eb52c1b49 [...] > you should send the shutdown > across, much like you copy data across: shutdown writing on the > other socket. Whic

Re: List of string

2005-08-18 Thread bryanjugglercryptographer
BranoZ wrote: > "132443" is a 'subsubstring' "0134314244133" because: For the record, that's called a "subsequence". http://www.google.com/search?hl=en&q=subsequence -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: __del__ pattern?

2005-08-16 Thread bryanjugglercryptographer
Chris Curvey wrote: > I need to ensure that there is only one instance of my python class on > my machine at a given time. (Not within an interpreter -- that would > just be a singleton -- but on the machine.) These instances are > created and destroyed, but there can be only one at a time. > > S

Re: __del__ pattern?

2005-08-16 Thread bryanjugglercryptographer
Tom Anderson wrote: > On Mon, 15 Aug 2005, Chris Curvey wrote: > > > Is there a better pattern to follow than using a __del__ method? I just > > need to be absolutely, positively sure of two things: > > An old hack i've seen before is to create a server socket - ie, make a > socket and bind it to

Re: base64.encode and decode not correct

2005-08-16 Thread bryanjugglercryptographer
Damir Hakimov wrote: > I found a strange bug in base64.encode and decode, when I try to encode > - decode a file 1728512 bytes lenth. > Is somebody meet with this? I don't attach the file because it big, but > can send to private. I agree the file is too big, but can you show a small Python prog

Re: Bug in slice type

2005-08-15 Thread bryanjugglercryptographer
Michael Hudson wrote: > Bryan Olson writes: > In some sense; it certainly does what I intended it to do. [...] > I'm not going to change the behaviour. The docs probably aren't > especially clear, though. The docs and the behavior contradict: [...] these are the /start/ and /stop/ indices

Re: socket setdefaulttimeout

2005-08-15 Thread bryanjugglercryptographer
Michael P. Soulier wrote: > On 13/08/05 Bryan Olson said: > > > The seperate thread-or-process trick should work. Start a deamon > > thread to do the gethostbyname, and have the main thread give up > > on the check if the deamon thread doesn't report (via a lock or > > another socket) within, say,