Re: binascii.unhexlify ... not clear about usage, and output
On May 30, 1:31 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Vishal wrote: > > I have a file with a long list of hex characters, and I want to get a > > file with corresponding binary characters > > > here's what I did: > > >>>> import binascii > >>>> f1 = 'c:\\temp\\allhex.txt' > >>>> f2 = 'c:\\temp\\allbin.txt' > >>>> sf = open(f1, 'rU') > >>>> df = open(f2, 'w') > >>>> slines = sf.readlines() > >>>> for line in slines: > > ... x = line.rstrip('\n') > > ... y = binascii.unhexlify(x) > > ... df.write(y) > > ... > >>>> df.close() > >>>> sf.close() > > Your code is OK, but you have to open f2 in binary mode if your data is > truly binary (an image, say). > > > But what I get is all garbage, atleast textpad and notepad show that > > I tried doing it for only one string, and this is what I am seeing on > > the interpreter: > > >>>> x > > '0164' > >>>> y > > '\x01d' > > > I was expecting 'y' would come out as a string with binary > > characters!!! > > What are "binary characters"? > > > What am i missing here? Can someone please help. > > What /exactly/ did you expect? Note that "\x01d" and "\x01\x64" are just > different renderings of the same string chr(0x01) + chr(0x64). > > Peter Thanks Peter for the explanation. Actually what I want is: if Input is 0x0164, Output should be: 000101100100 where each nibble is separated and the output appears in terms of '0's and '1's. Can I do that with this function binascii.unhexlify()??? Thanks and best regards, Vishal -- http://mail.python.org/mailman/listinfo/python-list
binascii.unhexlify ... not clear about usage, and output
Hi, I have a file with a long list of hex characters, and I want to get a file with corresponding binary characters here's what I did: >>> import binascii >>> f1 = 'c:\\temp\\allhex.txt' >>> f2 = 'c:\\temp\\allbin.txt' >>> sf = open(f1, 'rU') >>> df = open(f2, 'w') >>> slines = sf.readlines() >>> for line in slines: ... x = line.rstrip('\n') ... y = binascii.unhexlify(x) ... df.write(y) ... >>> df.close() >>> sf.close() But what I get is all garbage, atleast textpad and notepad show that I tried doing it for only one string, and this is what I am seeing on the interpreter: >>> x '0164' >>> y '\x01d' I was expecting 'y' would come out as a string with binary characters!!! What am i missing here? Can someone please help. Thanks and best regards, Vishal -- http://mail.python.org/mailman/listinfo/python-list
Regd. Regular expressions PyQt
Hello All: I am trying to work out a regular expression in a PyQt environment for time in hh:mm:ss format. Any suggestions? Thanks, Vishal -- http://mail.python.org/mailman/listinfo/python-list
Regd. Kodos
I am trying to use Kodos..but not getting thru'..dont know whats goin on..does anyone have a regular expression for time in hh:mm:ss -Vishal -- http://mail.python.org/mailman/listinfo/python-list
HELP NEEDED ... Regd. Regular expressions PyQt
Hello All: I am trying to work out a regular expression in a PyQt environment for time in hh:mm:ss format. Any suggestions? Thanks, Vishal -- http://mail.python.org/mailman/listinfo/python-list
How to check in CGI if client disconnected
Hi, I am writing a CGI to serve files to the caller. I was wondering if there is any way to tell in my CGI if the client browser is still connected. If it is not, i want to execute some special code before exiting. Is there any way to do this? Any help on this is appreciated :) Regards, -vishal. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check in CGI if client disconnected
Hi, Thanks for the replies. In my case, the cgi is sending a large file to the client. In case the the stop button is pressed on the browser to cancel the download, i want to do some cleanup action. It's all one- way transfer in this case, so i can't expect the client to send anything to me. I read somewhere that apache sends the SIGTERM signal to a cgi when the client disconnects. However, my cgi is not getting the signal - is there a way to have the cgi catch and handle the SIGTERM? I tried using the signal module --- def sigtermHandler(signum, frame): # do some cleanup signal.signal(signal.SIGTERM, sigtermHandler) --- But even this doesn't work. Regards, -vishal. On Aug 25, 2:58 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 24 Aug 2008 17:51:36 -0300, Wojtek Walczak <[EMAIL PROTECTED]> > escribió: > > > On Sun, 24 Aug 2008 17:21:52 -0300, Gabriel Genellina wrote: > >>> I am writing a CGI to serve files to the caller. I was wondering if > >>> there is any way to tell in my CGI if the client browser is still > >>> connected. If it is not, i want to execute some special code before > >>> exiting. > > >>> Is there any way to do this? Any help on this is appreciated :) > > >> I don't think so. A CGI script runs once per request, and exits. The > >> server may find that client disconnected, but that may happen after the > >> script finished. > > > I am not a web developer, but I think that the only way is to > > set a timeout on server side. You can't be sure that the client > > disconnected, but you can stop CGI script if there's no > > action on client side for too long. > > Which kind of client action? Every link clicked or form submitted generates a > different request that triggers a CGI script; the script starts, reads its > parameters, do its task, and exits. There is no "long running process" in CGI > - the whole "world" must be recreated on each request (a total waste of > resources, sure). > > If processing takes so much time, it's better to assign it a "ticket" - the > user may come back later and see if its "ticket" has been finished, or the > system may send an email telling him. > > -- > Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check in CGI if client disconnected
Hi Graham, Thanks for the reply. In my case, it's the other way round. I need to check if the amount of data sent is equal to the file size i want to send. However, the question is - when do i check this? Currently, i am unable to call any cleanup code before exit. Regards, -vishal. On Aug 25, 11:44 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Aug 25, 4:26 pm, Vishal <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > Thanks for the replies. In my case, the cgi is sending a large file > > to the client. In case the the stop button is pressed on the browser > > to cancel the download, i want to do some cleanup action. It's all one- > > way transfer in this case, so i can't expect the client to send > > anything to me. I read somewhere that apache sends the SIGTERM signal > > to a cgi when the client disconnects. However, my cgi is not getting > > the signal - is there a way to have the cgi catch and handle the > > SIGTERM? > > > I tried using the signal module > > > --- > > def sigtermHandler(signum, frame): > > # do some cleanup > > > signal.signal(signal.SIGTERM, sigtermHandler) > > > --- > > > But even this doesn't work. > > Have you considered simply checking to see if the amount of POST > content read matches the inbound Content-Length specified in the CGI > environment. If your processing of POST content finds less than what > was meant to be sent, then likely that the client browser aborted > request before all content could be sent. > > Graham > > > Regards, > > > -vishal. > > On Aug 25, 2:58 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > > wrote: > > > > En Sun, 24 Aug 2008 17:51:36 -0300, Wojtek Walczak <[EMAIL PROTECTED]> > > > escribió: > > > > > On Sun, 24 Aug 2008 17:21:52 -0300, Gabriel Genellina wrote: > > > >>> I am writing a CGI to serve files to the caller. I was wondering if > > > >>> there is any way to tell in my CGI if the client browser is still > > > >>> connected. If it is not, i want to execute some special code before > > > >>> exiting. > > > > >>> Is there any way to do this? Any help on this is appreciated :) > > > > >> I don't think so. A CGI script runs once per request, and exits. The > > > >> server may find that client disconnected, but that may happen after > > > >> the script finished. > > > > > I am not a web developer, but I think that the only way is to > > > > set a timeout on server side. You can't be sure that the client > > > > disconnected, but you can stop CGI script if there's no > > > > action on client side for too long. > > > > Which kind of client action? Every link clicked or form submitted > > > generates a different request that triggers a CGI script; the script > > > starts, reads its parameters, do its task, and exits. There is no "long > > > running process" in CGI - the whole "world" must be recreated on each > > > request (a total waste of resources, sure). > > > > If processing takes so much time, it's better to assign it a "ticket" - > > > the user may come back later and see if its "ticket" has been finished, > > > or the system may send an email telling him. > > > > -- > > > Gabriel Genellina > > -- http://mail.python.org/mailman/listinfo/python-list
Idea for removing the GIL...
Hello, This might sound crazy..and dont know if its even possible, but... Is it possible that the Python process, creates copies of the interpreter for each thread that is launched, and some how the thread is bound to its own interpreter ? This will increase the python process size...for sure, however data sharing will remain just like it is in threads. and it "may" also allow the two threads to run in parallel, assuming the processors of today can send independent instructions from the same process to multiple cores? Comments, suggestions, brush offs are welcome :)) I heard that this has been tried before...any info about that? Thanks and best regards, Vishal Sapre -- http://mail.python.org/mailman/listinfo/python-list
Re: Idea for removing the GIL...
On Feb 8, 3:05 pm, Adam Tauno Williams wrote: > On Tue, 2011-02-08 at 01:39 -0800, Vishal wrote: > > Is it possible that the Python process, creates copies of the > > interpreter for each thread that is launched, and some how the thread > > is bound to its own interpreter ? > > and it "may" also allow the two threads to run in parallel, assuming > > the processors of today can send independent instructions from the > > same process to multiple cores? > > Comments, suggestions, brush offs are welcome :)) > > Yes, it is possible, and done. See the multiprocessing module. It > works very well. > <http://docs.python.org/library/multiprocessing.html> > > It isn't exactly the same as threads, but provides many similar > constructs. Hi, Pardon me for my ignorance here, but 'multiprocessing' creates actual processes using fork() or CreateProcess(). I was talking of a single process, running multiple instances of the interpreter. Each thread, bound with its own interpreter. so the GIL wont be an issue anymore...each interpreter has only one thing to do, and that one thing holds the lock on its own interpreter. Since its still the same process, data sharing should happen just like in Threads. Also, multiprocessing has issues on Windows (most probably because of the way CreateProcess() functions...) Thanks and best regards, Vishal -- http://mail.python.org/mailman/listinfo/python-list
Resolution of paths in tracebacks
When an exception occurs, the full path to the file from which it originates is displayed, but redundant elements are not removed. For instance: $ ./python ./foo Traceback (most recent call last): File "/home/User/cpython/./foo", line 4, in a() File "/home/User/cpython/./foo", line 3, in a def a(): raise ValueError ValueError This happens because the function _Py_abspath (in Python/fileutils.c) appends relative_path_to_file to absolute_path_to_current_working_directory. Not sure if this should be treated as a bug, because the definition of 'absolute path' is not clear. Does it mean a path starting from the root directory, or a path without redundant elements? The os module, for instance, does the following. $ ./python >>> import os.path >>> os.path.isabs('/home/..') True >>> os.path.abspath('/home/..') '/' Either way: should the traceback display the path without redundant elements? I am using CPython 3.13.0a0 (595ffddb33e95d8fa11999ddb873d08e3565d2eb). -- https://mail.python.org/mailman/listinfo/python-list
pip3 : command not found
Hi, So I wads trying to install some packages for python3. when I run pip3 in terminal i receive the error "pip3 : command not found". When looking at the path, I noticed /usr/local/Cellar/python3/3.5.2_3 does not have pip3 in the directory while /usr/local/Cellar/python3/3.5.2_2 does have. I am guessing this is the issue. I tried using the get-pip.py and that didnt work either. When I search for pip I find pip, pip2 and pip2.7 all of which are for python 2.7. I tried uninstalling python3 and reinstalling but that didnt work either. I am running this on Mac OS Sierra. Please let me know how I can fix this. Looking forward to your response. Regards, Vishal Subbiah Institute for Computational and Mathematical Engineering Masters Student Stanford University -- https://mail.python.org/mailman/listinfo/python-list
Re: pip3 : command not found
Hi, Thanks Ben for the response. I followed your suggestion and this is what i get: "python3 -m pip3 install LoremIpsum /usr/local/opt/python3/bin/python3.5: No module named pip3" "python3 -m pip install LoremIpsum /usr/local/opt/python3/bin/python3.5: No module named pip" How do I fix this? Regards, Vishal Subbiah Institute for Computational and Mathematical Engineering Masters Student Stanford University On Sun, Oct 30, 2016 at 5:37 PM, Ben Finney wrote: > Vishal Subbiah writes: > > > So I wads trying to install some packages for python3. when I run pip3 > > in terminal > > There is no guarantee that a command named ‘pip3’ will be installed. > > Instead, you should invoke the exact Python interpreter you want – and, > by extension, the Python environment into which you want packages > installed. > > $ /foo/bar/virtualenv/bin/python3 -m pip install LoremIpsum > > If you already have a specific environment active and know that > ‘python3’ is the correct Python interpreter from that environment, you > can omit the explicit path. > > $ python3 -m pip install LoremIpsum > > > > Why doesn't a command ‘pip’ or ‘pip3’ do the job? Because there's no > guarantee that will use the specific Python environment you want. > > For many programs, it simply doesn't matter which Python interpreter – > or even *whether* a Python interpreter or Perl interpreter or etc. – is > the one that runs. > > So most Python-implemented programs you don't need to specify which > interpreter; they know how to find it themselves, and your choice of a > different environment should not affect their operation. > > But for a command that has the primary purpose of interacting with that > environment – by installing or removing packages, as Pip does – it must > obey your explicit instruction on which Python environment and > interpreter to use. > > -- > \ “It ain't so much the things we don't know that get us in | > `\trouble. It's the things we know that ain't so.” —Artemus Ward | > _o__) (1834–1867), U.S. journalist | > Ben Finney > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Python MySQL Guide
Sure, no problem. I also added a table of contents at the start of the article you can also refer that On Fri, 10 Aug 2018, 6:43 pm Bob Gailer, wrote: > Thank you for this offer. My reaction is I don't like having to scroll > through one very long page to find what I'm looking for. Might you consider > breaking it up into a number of smaller pages and giving an index as the > main page? > > On Aug 9, 2018 5:18 PM, wrote: > >> Refer this complete guide on working with Python and MySQL >> >> https://pynative.com/python-mysql-tutorial/ >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > -- https://mail.python.org/mailman/listinfo/python-list
Simple Python Based Genetic Algorithm Framework
Check out a new and simple Python base genetic algorithm framework at http://vishpat.googlepages.com/pgap -- Motivation will almost always beat mere talent. -- http://mail.python.org/mailman/listinfo/python-list
Compatibility of python2.5 with pytohn2.3
Hi all, I am new member of this post. I have a C application which uses Python(version 2.3) extensively with SWIG wrappers. I want to upgrade the Python to latest version2.5. Is there any compatibility issue between two versions? Does latest Python2.5 provide backward compatibility to previous Python (Version 2.3 in my case) constructs. Thanks, Vishal -- http://mail.python.org/mailman/listinfo/python-list
RE: Watching a file another app is writing
What kind of file is it? CSV? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeremy Sanders Sent: Monday, March 12, 2007 11:26 AM To: python-list@python.org Subject: Re: Watching a file another app is writing Gordon Airporte wrote: > I'm trying to find a way to take a file that another program has opened > and writes to periodically, open it simultaneously in Python, and > automatically update some of my objects in Python when the file is > written to. > I can open the file and manually readlines() from it to keep up to date, > it's the automatic part I'm having trouble with. This is on Windows. It occurs to me under Unix you could perhaps get your first program to write to a "named pipe", which you 2nd program could read from. See http://en.wikipedia.org/wiki/Named_pipe Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Closing pexpect connections using threads
I am trying to write a multi-threaded program and use pexpect along with it. All works fine until I try to close the connection handle. That thread keeps waiting until the connection handle closes. It actually never comes out of that command(connection_handle.close()). If I manually kill it using kill command, the thread comes out and quits otherwise it is in the wait state forever. def daemon(self): self.continue_hearbeats_lock.acquire() self.continue_heartbeats = True self.continue_hearbeats_lock.release() thrdHandshake = threading.Event() threading.Thread(target=self.RunTests,name='Run_Te st_Thread') while self.continue_heartbeats: pass def RunTests(self): self.createconnection() self.closeconnection() def closeconnection() self.log("Closing connection for device") self.connection_handle.close() createconnection is a API which creates SSH connection to a remote machine. And upon running, it hangs at this point 11:8:17:910 [DBG][CLEANUP] 11:8:17:910 [DBG]Closing Connection for device Any tips on what I am missing here? Thanks, -V -- http://mail.python.org/mailman/listinfo/python-list
Owner of spawned process in threads
Just trying to understand the behaviour of spawn. Consider I have a function which creates two threads. And in one of the threads I make a call to pexpect.spawn. spawn would fork and create a new new child In this case who becomes the owner of this child process. Is it the thread that spawned becomes the owner or is the main program becomes the owner of that child process. Thanks, -V -- http://mail.python.org/mailman/listinfo/python-list
RE: can't find a way to display and print pdf through python.
Use Report Lab... Cheers, Vishal -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of krishnakant Mane Sent: Saturday, February 10, 2007 10:46 PM To: python-list@python.org Subject: can't find a way to display and print pdf through python. hello all, I am stuck with a strange requirement. I need a library that can help me display a pdf file as a report and also want a way to print the same pdf file in a platform independent way. if that's not possible then I at least need the code for useing some library for connecting to acrobat reader and giving the print command on windows and some thing similar on ubuntu linux. the problem is that I want to display reports in my application. the user should be able to view the formatted report on screen and at his choice click the print button on the screen to send it to the printer. I have reportlab installed and that is sufficient to generate pdf reports. but I still can't fine the way to display it directly and print it directly. Please help me. Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: can't find a way to display and print pdf through python.
Are you trying to do real time or post real time. -Vishal -Original Message- From: krishnakant Mane [mailto:[EMAIL PROTECTED] Sent: Saturday, February 10, 2007 10:50 PM To: Vishal Bhargava Cc: python-list@python.org Subject: Re: can't find a way to display and print pdf through python. On 11/02/07, Vishal Bhargava <[EMAIL PROTECTED]> wrote: > Use Report Lab... I mentioned in my first email that I am already using reportlab. but I can only generate pdf out of that. I want to display it on screen and I also will be giving a print button which should do the printing job. by the way I use wxpython for gui. Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list
Regd. converting seconds to hh:mm:ss format
Is there an inbuilt library in Python which you can use to convert time in seconds to hh:mm:ss format? Thanks, Vishal -- http://mail.python.org/mailman/listinfo/python-list
base32hex support in python?
Hi, One of the modules that I am currently working on requires base32hex encoding as defined by RFC 4648, section 7. I checked base64 module which has base32encode/decode functionality but not with extended hex alphabet. Is there a module, currently available, that provides this? As far as I see, it looks fairly simple to add support for base32hex. It differs from the base32 encoding only in the alphabet used. I am willing to provide a patch. Just to note, map01 argument won't be applicable to base32hexdecode as this encoding uses both 0 (zero) and O (oh) in its alphabet. Looking at the section 13 of RFC 4648, I think, adding base32hex support would make it conform to RFC 4648. - Vishal DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. -- http://mail.python.org/mailman/listinfo/python-list
Constructing an if statement from the client data in python
Hi, I need to construct an if statement from the data coming from the client as below: conditions: condition1, condition2, condition3, condition4 logical operators: lo1, lo2, lo3 (Possible values: "and" "or") Eg. if condition1 lo1 condition2 lo3 condition4: # Do something I can think of eval/exec but not sure how safe they are! Any better approach or alternative? Appreciate your responses :) PS: Client-side: Flex, Server-side: Python, over internet Thanks Vishal -- http://mail.python.org/mailman/listinfo/python-list
Re: Constructing an if statement from the client data in python
They are bitwise operators! Thanks Vishal Rana -- http://mail.python.org/mailman/listinfo/python-list
Re: Constructing an if statement from the client data in python
They are bitwise operators! Thanks Vishal Rana -- http://mail.python.org/mailman/listinfo/python-list
Re: Constructing an if statement from the client data in python
They are bitwise operators! -- http://mail.python.org/mailman/listinfo/python-list
Re: Constructing an if statement from the client data in python
Thanks Chris On Tue, Apr 13, 2010 at 1:08 PM, Chris Rebert wrote: > > On Tue, Apr 13, 2010 at 12:29 PM, Chris Rebert > wrote: > >> On Tue, Apr 13, 2010 at 8:56 AM, Vishal Rana > wrote: > >> > Hi, > >> > > >> > I need to construct an if statement from the data coming from the > client > >> > as > >> > below: > >> > > >> > conditions: condition1, condition2, condition3, condition4 logical > >> > operators: lo1, lo2, lo3 (Possible values: "and" "or") > >> > > >> > Eg. > >> > > >> > if condition1 lo1 condition2 lo3 condition4: > >> > > >> > # Do something > >> > > >> > I can think of eval/exec but not sure how safe they are! Any better > >> > approach > >> > or alternative? Appreciate your responses :) > >> > > >> > PS: Client-side: Flex, Server-side: Python, over internet > >> > >> Do you literally get a string, or do/could you get the expression in a > >> more structured format? > > On Tue, Apr 13, 2010 at 12:46 PM, Vishal Rana > wrote: > > Its a form at the client side where you can construct a query > > using different conditions and logical operators. > > I can take it in any format!, currently it comes as a parameters to an > RPC. > > Well, then if possible, I'd have the form send it back in a Lisp-like > format and run it through a simple evaluator: > > def and_(conds, context): >for cond in conds: >if not evaluate(cond, context): >return False >return True > > def or_(conds, context): >for cond in conds: >if evaluate(cond, context): >return True >return False > > def greater_than(pair, context): >left, right = [context[name] for name in pair] >return left > right > > OPNAME2FUNC = {"and" : and_, "or" : or_, ">" : greater_than} > > def evaluate(expr, context): >op_name, operands = expr[0], expr[1:] >return OPNAME2FUNC[op_name](operands, context) > > expression = ["and", [">", "x", "y"], ["or", [">", "y", "z"], [">", "x", > "z"]]] > variables = {"x" : 7, "y" : 3, "z" : 5} > print evaluate(expression, variables) > > If it's just ands and ors of bare variables (no '>' or analogous > operations), the code can be simplified a bit. > > Cheers, > Chris > -- > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Updating a module level shared dictionary
Hi, A module level dictionary 'd' and is accessed by different threads/requests in a django web application. I need to update 'd' every minute with a new data and the process takes about 5 seconds. What could be best solution where I want the users to get either the old value or the new and nothing in between. I can think of a solution where a temp dictionary is constructed with a new data and assigned to 'd' but now sure how this works! Appreciate your ideas. Thanks -- http://mail.python.org/mailman/listinfo/python-list
A daemon to call a function with configurable interval
Hi, I am working in a django web application. A function 'xyx' need to be called every 2 minutes. I want one http request should start the daemon and keep calling xyz (every 2 minutes) until I send another http request to stop it. Appreciate your ideas. Thanks Vishal Rana -- http://mail.python.org/mailman/listinfo/python-list
How is memory managed in python?
Hi, In my web application (Django) I call a function for some request which loads like 500 MB data from the database uses it to do some calculation and stores the output in disk. I just wonder even after this request is served the apache / python process is still shows using that 500 MB, why is it so? Can't I release that memory? Thanks Vishal Rana -- http://mail.python.org/mailman/listinfo/python-list
Re: How is memory managed in python?
Chris, Thanks for the link. On Mon, Jul 19, 2010 at 11:43 PM, Chris Rebert wrote: > On Mon, Jul 19, 2010 at 6:30 PM, Vishal Rana wrote: > > Hi, > > In my web application (Django) I call a function for some request which > > loads like 500 MB data from the database uses it to do some calculation > and > > stores the output in disk. I just wonder even after this request is > served > > the apache / python process is still shows using that 500 MB, why is it > so? > > Can't I release that memory? > > > http://effbot.org/pyfaq/why-doesnt-python-release-the-memory-when-i-delete-a-large-object.htm > > There are multiple layers of memory allocation involved. To avoid > thrashing+fragmentation and to improve efficiency, free memory is not > always immediately returned to the operating system. Example: If your > problem involved calling your 500MB function twice, free-ing after the > first call and then immediately re-allocating another 500MB of memory > for the second call would waste time. > > Cheers, > Chris > -- > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Re: How is memory managed in python?
Hi Christian, I am not sure which one is used in this case, I use htop to see the memory used by apache / python. Thanks Vishal Rana On Tue, Jul 20, 2010 at 5:31 AM, Christian Heimes wrote: > > In my web application (Django) I call a function for some request which > > loads like 500 MB data from the database uses it to do some calculation > and > > stores the output in disk. I just wonder even after this request is > served > > the apache / python process is still shows using that 500 MB, why is it > so? > > Can't I release that memory? > > Are you talking about resident or virtual memory here? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: How is memory managed in python?
Thanks for your input. On Mon, Jul 19, 2010 at 7:23 PM, Scott McCarty wrote: > I had this exactly same problem with Peel and as far as I could find there > is no way reclaiming this memory unless you set max requests, which will > kill the Apache children processes after that number of requests. It's > normally something used for debugging, but can be used to reclaim ram. > > On the flip side, you could find your machine servers down and your child > processes will reuse that memory when they receive another request that uses > a huge amount of ram. It really depends on how often you are doing that > kind of processing, how you want to tune apache. > > Scott M > > On Jul 19, 2010 9:31 PM, "Vishal Rana" wrote: > > Hi, > > > > In my web application (Django) I call a function for some request which > > loads like 500 MB data from the database uses it to do some calculation > and > > stores the output in disk. I just wonder even after this request is > served > > the apache / python process is still shows using that 500 MB, why is it > so? > > Can't I release that memory? > > > > Thanks > > Vishal Rana > -- http://mail.python.org/mailman/listinfo/python-list
Re: How is memory managed in python?
Christian, It stays in RES and VIRT as well. Thanks Vishal Rana On Tue, Jul 20, 2010 at 8:53 AM, Christian Heimes wrote: > Am 20.07.2010 17:50, schrieb Vishal Rana: > > Hi Christian, > > > > I am not sure which one is used in this case, I use htop to see the > memory > > used by apache / python. > > In its default configuration htop reports three different types of > memory usage: virt, res and shr (virtual, resident and shared memory). > Which of them stays at 500 MB? > > Christian > -- http://mail.python.org/mailman/listinfo/python-list
Help: Group based synchronize decorator
I want to synchronize calls using rw locks per 'group' and my implementation is similar to http://code.activestate.com/recipes/465057/ except that I have my own Lock implementation. All my synchronized functions take 'whatGroup' as param. My lock considers 'group' while deciding on granting locks through acquire. What I could come up with is: - decorator knows(assumes) first param to decorated functions is always 'whatGroup' - decorator passes this 'whatGroup' argument to my lock which is used in acquire logic. Is it ok to make such assumptions in decorator? Any suggestions/alternatives? thanks vishal DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: Help: Group based synchronize decorator
Thanks. - vishal > -Original Message- > Sent: Friday, June 19, 2009 3:15 PM > To: python-list@python.org > Subject: Python-list Digest, Vol 69, Issue 214 > > Message: 6 > Date: Fri, 19 Jun 2009 10:53:27 +0200 > From: Piet van Oostrum > To: python-list@python.org > Subject: Re: Help: Group based synchronize decorator > Message-ID: > Content-Type: text/plain; charset=us-ascii > > >>>>> Vishal Shetye (VS) wrote: > > >VS> I want to synchronize calls using rw locks per 'group' and my > implementation is similar to > >VS> http://code.activestate.com/recipes/465057/ > >VS> except that I have my own Lock implementation. > > >VS> All my synchronized functions take 'whatGroup' as param. My lock > considers 'group' while deciding on granting locks through acquire. > > >VS> What I could come up with is: > >VS> - decorator knows(assumes) first param to decorated functions is > always 'whatGroup' > >VS> - decorator passes this 'whatGroup' argument to my lock which is used > in acquire logic. > > >VS> Is it ok to make such assumptions in decorator? > > As long as you make sure that all decorated functions indeed adhere to > that assumption there is nothing wrong with it. > -- > Piet van Oostrum > URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] > Private email: p...@vanoostrum.org DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. -- http://mail.python.org/mailman/listinfo/python-list
CodeFest - Online Coding Festival by Computer Engineering Society, IT-BHU
Hello, We are delighted to inform you that CodeFest, the annual International online coding festival of Computer Engineering Society, IT-BHU, has been unveiled. CodeFest is a unique fest wherein concepts of mathematics, logic, artificial intelligence, algorithms, language syntax, etc. are required to be deployed in programming; these concepts manifest themselves in solving problems effectively and efficiently! CodeFest was started last year. CodeFest'10 was a phenomenal success with participation from all over the globe. CodeFest'11 is geared up with some new and pepped up events, while maintaining the integrity of its standards. Here is a brief description of the constituent online events: * Mathmania: A mathematical puzzle contest that puts mathematical and computational skills to test. * Manthan: An algorithm intensive programming contest that would require coders to tailor existing standard algorithms to solve real life computation problems. * Virtual Combat: An educational game wherein teams of programmed robotic tanks will fight the battles for glory. Codes Do Fight! Watch this out. * Perplexed: A programming contest, aimed to test the knowledge of C, wherein codes will be rewarded against syntactic constraints. * Ratespiel: A technical quiz covering different areas of Computer Science. This year CodeFest, in association with Technex'11, brings onsite events: * Eniac: An open software exhibition where you get an opportunity to demonstrate your software from any domain. * Code Warrior: A multiple round contest to award the title of 'ultimate computer geek'. Visit our website to get more details. Few exciting statistics about CodeFest'10: * 2354 registrations (including 128 professionals) from 680 different institutions, across 59 countries. * Some participants were among the winners of Google Code Jam, Top Coder SRMs and ACM ICPC. * Total prize money was a whopping amount of 260,000 INR! * CodeFest '10 was the largest online coding festival of the Indian subcontinent in 2010 in terms of prize money! * CodeFest'10 was the second largest online coding festival of the Indian subcontinent in 2010, next to Bitwise. * Gained recognition from several international organizations including Codechef, Adobe, British Telecom, TCS and IEEE. The CodeFest'11 team has set out to unleash a coding extravaganza. You can't afford to miss the chance to be a part of this fest! Still have any questions? Feel free to contact us at codef...@itbhu.ac.in or reach us personally at: * Mohit Bansalmohit.bansal.cs...@itbhu.ac.in * Saket Saurabh +91-9452-825-690 saket.saurabh.cs...@itbhu.ac.in We wish you all the best for CodeFest and for your future endeavors. Be free and Happy Coding! Team CodeFest IT-BHU -- http://mail.python.org/mailman/listinfo/python-list
Multi-language programing playground
Folks, I wanted to share a multi-language programming playground that I created recently. I hope you will find it useful. https://code.labstack.com/program Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: TkInter Scrolled Listbox class?
This is what I created ScrollableContainers for. Its usage deviates a bit from standard Tkinter practices in that you add widgets to the frame attribute of a ScrollableFrameTk instance. [1]twitter.abaf4b19.webp [2]ScrollableContainers pypi.org For your use case, you could populate your list box and then put it inside that frame. I’ve not tested this scenario, so I’d appreciate feedback! Thanks. On 4 Nov 2024, at 21:28, Ulrich Goebel via Python-list wrote: Hi, I would like to build a class ScrolledListbox, which can be packed somewhere in ttk.Frames. What I did is to build not really a scrolled Listbox but a Frame containing a Listbox and a Scrollbar: class FrameScrolledListbox(ttk.Frame): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # # build Listbox and Scrollbar self.Listbox = tk.Listbox(self) self.Scrollbar = ttk.Scrollbar(self) # # configure these two self.Listbox.config(yscrollcommand=self.Scrollbar.set) self.Scrollbar.config(command=self.Listbox.yview) # # pack them in Frame self.Listbox.pack(side=tk.LEFT, fill=tk.BOTH) self.Scrollbar.pack(side=tk.RIGHT, fill=tk.BOTH) That works, so instances of FrameScrolledListbox can be packed and the tk.Listbox itself is accessible via an attribute: frmScrolledListbox = FrameScrolledListbox(main) frmScrolledListbox.Listbox.config(...) But it would be a bit nicer to get a class like class ScrolledListbox(tk.Listbox): ... So it would be used that way: scrolledListbox = ScrolledListbox(main) scrolledListbox.config(...) Is that possible? The problem which I can't handle is to handle the Frame which seems to be needed to place the Scrollbar somewhere. Best regards Ulrich -- Ulrich Goebel -- https://mail.python.org/mailman/listinfo/python-list References Visible links 1. https://pypi.org/project/ScrollableContainers/ 2. https://pypi.org/project/ScrollableContainers/ -- https://mail.python.org/mailman/listinfo/python-list