Core Dump - Segmentation Fault -Newbie


Hi - I am very new to python. I get this random core dump and am looking for a good way to catch the error. I know the function my core dump occurs. Is there any error catching/handling that I ...
Posted On: Sunday 25th of November 2012 09:04:36 PM Total Views:  84
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Integrating a GUI with an asyncore-based server

. Just for the heck of it I'd like to write a simple front-end for an asyncore-based server I wrote by using Tkinter. I wrote a simple graphical interface consisting of two buttons: "Start server" and "Stop server". The first button should start the asyncore main loop while the second should obviously stop it. Actually I can't find a valid solution for doing such a stuff since this is the first time I'm using a GUI toolkit. Which is the best approach to use in such case Could someone point me in the right direction
VIEWS ON THIS POST

224

Posted on:

Monday 5th November 2012
View Replies!

highscores list

I'm writing a game that uses two functions to check and see if a file called highScoresList.txt exists in the main dir of the game program. If it doesn, it creates one. That part is working fine. The problem is arising when it goes to read in the high scores from the file when I play again. This is the error msg python is giving me Traceback (most recent call last): File "", line 1, in main() File "I:\PYTHON\PROJECT #3\PROJECT3.PYW", line 330, in main if(hasHighScore(wins) == True): File "I:\PYTHON\PROJECT #3\PROJECT3.PYW", line 175, in hasHighScore scores[i],names[i] = string.split(line,"\t") ValueError: need more than 1 value to unpack Here's the relavant code: def hasHighScore(score): #opens highScoresList.txt infile = open("highScoresList.txt",'r') scores = [0,0,0] names = ["","",""] #reads in scores from highScoresList.txt i=0 for line in infile.readlines(): scores[i],names[i] = string.split(line,"\t") names[i]=string.rstrip(names[i]) i += 1 infile.close() #compares player's score with those in highScoresList.txt i=0 for i in range(0,len(scores)): if(score > int(scores[i])): return True else: return False def setHighScores(score,name): #opens highScoresList.txt infile = open("highScoresList.txt",'r') scores = [0,0,0] names = ["","",""] #reads in scores from highScoresList.txt i=0 for line in infile.readlines(): scores[i],names[i] = string.split(line,"\t") scores[i]=int(scores[i]) names[i]=string.rstrip(names[i]) i += 1 infile.close() #shuffles thru the highScoresList.txt and inserts player's score if higher then those in file i=len(scores) while(score > scores[i-1] and i>0): i -= 1 scores.insert(i,score) names.insert(i,name) scores.pop(len(scores)-1) names.pop(len(names)-1) #writes new highScoresList.txt outfile = open("highScoresList.txt","w") outfile.write (" High Score Name \n") outfile.write ("-------------------------------------------------\n") i=0 for i in range(0,len(scores)): outfile.write("\t" + str(scores[i]) + "\t\t\t" + names[i] + "\n") outfile.close() And here's the call to the functions at the end of my game, included in the error msg. #adds player's score to high score list if high enough if(hasHighScore(wins) == True): setHighScores(wins,getName(wins)) And this is what the text file looks like when it happens. High Score Name ------------------------------------------------- 15 SHAWN 0 0 The answer is probably simple, I've just been working on this program so long that my brain has turned to mush.
VIEWS ON THIS POST

136

Posted on:

Monday 5th November 2012
View Replies!

AIX Subversion Python Swig Bindings fix for core dump

If you're on AIX and Python immediately dumps core when trying to import any SVN module, then adding "-Wl,-brtl" to LINKFORSHARED in the Makefile seems to fix the problem. Bad: > LINKFORSHARED= -Wl,-bE:Modules/python.exp -lld Good: < LINKFORSHARED= -Wl,-bE:Modules/python.exp -lld -Wl,-brtl 1. unset PYTHONPATH 2. ./configure --without-gcc --disable-ipv6 --with-thread CC=/usr/vac/bin/xlc_r CXX=/usr/vacpp/bin/xlC_r 3. Edit Makefile: LINKFORSHARED= -Wl,-bE:Modules/python.exp -lld -Wl,-brtl 4. make CC=/usr/vac/bin/xlc_r CXX=/usr/vacpp/bin/xlC_r OPT="-O2 -qmaxmem=4000" 5. make install Oddly enough, there was no need to build Python using shared libraries. ("#*shared* in Modules/Setup was left commented out and --enable-shared was not used.) The OPT="..." is described in Python-2.5.1/Misc/AIX-NOTES. This was on AIX 5.3, xlc_r 9.0, Python 5.2.1, Subversion 1.4.5. It also appears to work using gcc and Python 2.4.4.
VIEWS ON THIS POST

128

Posted on:

Monday 5th November 2012
View Replies!

asyncore and OOB data

, In an asyncore based FTP server I wrote I should be able to receive OOB data from clients. A client sending such kind of data should act like this: >>> import socket >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> s.connect(('127.0.0.1', 21)) >>> s.sendall('hello there\r\n', socket.MSG_OOB) According to asyncore documentation I should handle this kind of event in "handle_expt" method of dispatcher class, that should be called when OOB is received by the underlying socket. I've tried to override handle_expt method in such way: def handle_expt(self): print "OOB data arrived" data = self.socket.recv(1024, socket.MSG_OOB) print data ....but, even if it is called, "data" contains only a "\n" character instead of the entire string ("hello there\r\n"). Why does this happen Should I have to use a different approach
VIEWS ON THIS POST

118

Posted on:

Monday 5th November 2012
View Replies!

Re: need advice on building core code for python and PHP

On May 24, 5:01 pm, Graham Dumpleton wrote: > On May 25, 5:24 am, aspineux wrote: > > > > > On 24 mai, 19:33, Szabolcs Nagy wrote: > > > > > Is there a way I could code the base (core) code in Python and have > > > > PHP call it I've really liked using SQLAlchemy and there are other > > > > * quick and dirty solution: > > > in a shell: > > > $ python yourscript.py pipe_out > > > in the php script: > > > fwrite(pipe_in, input_data); > > > results = fread(pipe_out, sizeof_results); > > > > * simple and nice solution: > > > do not ever use php > > > Write a CGI wrapper around your python script, and publish it using mod_python. > > And make the appropriate http requests from PHP. > > You do not need mod_python to host CGI scripts written in Python, they > are two separate things. > > Depending on the complexity of what you are doing, you might be better > off writing a backend server in Python that incorporates an XML-RPC > server. Your PHP script can then use XML-RPC client to communicate to > the backend Python server to do the real work. Over time you could > even transition your web pages to being done in Python instead. In > doing this your back end Python server doesn't have to change, you > just make XML-RPC calls from the Python code for the web pages in > place of where you would be doing it with PHP initially. You also > wouldn't be restricted to web based front ends, you could also use GUI > based front end as well. > > Graham This sounds more like the direction I should go. Is XML-RPC the only technology allowing this sort of setup If I understand correctly, it would basically mean going to a three tiered application approach. I'd have the database, the python xml-rpc server, and the gui/web interfaces. I'd also want to make sure I'm implementing technology that will scale well. Brian
VIEWS ON THIS POST

199

Posted on:

Monday 5th November 2012
View Replies!

Let's make Python the core system administration tool

My article, "Rethinking the Linux Distribution", was published today on O'Reilly ONLamp. http://www.onlamp.com/pub/a/onlamp/2...tribution.html I have done a lot of research on what the Linux distribution should look like in the emerging Web 2.0/SaaS/Web OS world, and came up with a set of recommendations. The recommendations are backed by running examples (with source code) and lots of references. The article also discusses governance of Free/Open Source projects. One of my major suggestions is to replace the traditional shell-based administration infrastructure with Python. I cover a relatively recent, highly rated Linux distribution, which has already started down this path. The article includes an example of using IPython and Matplotlib for system administration. Hope here will enjoy considering a Linux (or *BSD) distribution, where the core system infrastructure is all in Python. George.
VIEWS ON THIS POST

200

Posted on:

Monday 5th November 2012
View Replies!

ll-core 1.3 released

ll-core 1.3 has been released! What's new in version 1.3 ========================== * ll.make has been rewritten. Now there's no longer a distinction between Targets and Actions. Actions can be chained more easily and creating an action and registering it with the project are two separate steps. Actions can no longer be shared, as each action stores its own input actions (but output actions are not stored). "Ids" have been renamed to "keys" (and DBID/OracleID to DBKey/OracleKey. ImportAction has been renamed to ModuleAction and can now turn any string into a module. * In ll.url modification dates for local files now include microseconds (if the OS supports it). * A class Queue has been added to ll.misc which provides FIFO queues. * A decorator withdoc has been added to ll.misc that sets the docstring on the function it decorates. * setuptools is now supported for installation. Where can I get it =================== ll-core can be downloaded from http://ftp.livinglogic.de/core/ or ftp://ftp.livinglogic.de/pub/livinglogic/core/ Web pages are at http://www.livinglogic.de/Python/core/ ViewCVS access is available at http://www.livinglogic.de/viewcvs/ Bye, Walter Drwald
VIEWS ON THIS POST

111

Posted on:

Monday 5th November 2012
View Replies!

SciPy 0.4.3 released (built against 0.6.1 of scipy_core)

Background: Full scipy builds on top of scipy_core to provide many more tools for computational science and engineering. Included are tools for optimization, integration (including ode solvers), signal processing, sparse matrices, complete FFTs, complete linear algebra, statistical functions, input and output routines, interpolation, integration, and many special functions. SciPy 0.4.3 This version is the first release to build on top of the new scipy_core (v 0.6.1). The code is relatively stable, but there may be some lingering bugs from the transition from Numeric. Please report any errors you find. The LICENSE is a BSD style License---the same as scipy_core. More information can be found (some of which is dated) at http://www.scipy.org. The sourceforge site where it can be downloaded is http://sourceforge.net/projects/scipy. SciPy (full) 0.4.3 - Extension modules for scipy_core (12-Nov-05)
VIEWS ON THIS POST

98

Posted on:

Monday 5th November 2012
View Replies!

How can I check nbr of cores of computer?

How can I check how many cores my computer has Is it possible to do this in a Python-app
VIEWS ON THIS POST

116

Posted on:

Wednesday 7th November 2012
View Replies!

Trying to install module, No module named scipy_distutils.core (but ihave scipy)

trying to install PyKF-0.1 (Kalman Filters) http://pykf.sourceforge.net/ I have Numpy, Scipy, Matplotlib installed an have successfully installed other packages using them. $ setup.py Traceback (most recent call last): File "./setup.py", line 2, in from scipy_distutils.core import setup ImportError: No module named scipy_distutils.core #!/usr/bin/env python from scipy_distutils.core import setup version = "0.1" setup( version=version, author="Chris Fonnesbeck", author_email="fonnesbeck@mac.com", description="Version %s of PyKF" % version, license="GNU GPL", name="PyKF", url="pykf.sourceforge.net", packages=["PyKF"], )
VIEWS ON THIS POST

186

Posted on:

Wednesday 7th November 2012
View Replies!

Multicore-programming?

If I buy a multicore computer and I have really intensive program. How would that be distributed across the cores Will algorithms always have to be programmed and told specifically to run on several cores so if not told it will only utilize one core So is the free lunch really over or is this just an overhyped phenomena Is threading with Python hard Can you start several processes with Python or just threads
VIEWS ON THIS POST

105

Posted on:

Wednesday 7th November 2012
View Replies!

Re: GIL cpu multi core usage problem

En Fri, 13 Jun 2008 08:55:30 -0300, Pau Freixes escribi: > When you say this "C extensions (usually) release the GIL when they don't > call into any Python code" do you talk about this macros > > Py_BEGIN_ALLOW_THREADS > > Py_END_ALLOW_THREADS Exactly. -- Gabriel Genellina
VIEWS ON THIS POST

274

Posted on:

Wednesday 7th November 2012
View Replies!

Question on using distutils.core.run_setup

I'm trying to programmatically install something built using distutils. I found distutils.core.run_setup and can use it via >>> dist = run_setup('setup.py', ['-q', 'install']) Is that the recommended way to do an install from inside Python (as opposed to doing it on the command line) If so, how can I find where the thing(s) I installed now resides I saw dist.packages but that just has top-level package names. I could __import__ these (and then use module.__file__), but that's not a good solution as it may run code I don't want run. On my machine, I can see the packages have been installed under the system's python2.5/site-packages directory. But how can I determine that programmatically I don't see anything useful on the distutils.dist.Distribution instance I'm getting back from run_setup.
VIEWS ON THIS POST

180

Posted on:

Wednesday 7th November 2012
View Replies!

Asynchronous urllib (urllib+asyncore)?

So, I ran into a problem that I would like to write as little code as possible to solve. The problem is that I would like to send out a bunch of HTTP requests simultaneously, using asynchronous techniques, and then do stuff with the results in parallel. Think of something like Google's map-reduce. It sounds like this would be something someone else has done before. I searched google, but I don't think there is any discussion anywhere of anyone doing something like this. I am sure Twisted folks can code this up in 2 lines or less, or it probably already exists there by default. But I need this to exist in a non-asynchronous environment. I can't let Twisted take over everything. So, has someone done something like this Is it something where I can bring the urllib and asyncore together Or is it much more involved
VIEWS ON THIS POST

151

Posted on:

Wednesday 7th November 2012
View Replies!

Using a signal to terminate a programm running with an asyncore loop

I'm developing a program that runs using an asyncore loop. Right now I can adequately terminate it using Control-C, but as things get refined I need a better way to stop it. I've developed another program that executes it as a child process using popen2.Popen4(). I was attempting to use signals to stop it (using os.kill()) but I keep running into a problem where sending the signal causes an infinite loop of printing the message "warning: unhandled exception". This message appears to be coming from asyncore.py. Searching online I've found this old post that describes setting up a signal handler using signal.signal(): http://mail.python.org/pipermail/med...00/000571.html I've tried it but I don't see any indication that my handler method is being called. My best guess is that something somewhere else is overriding my signal handling callbacks and sending the signals elsewhere until they make their way into asyncore where they cause the error message. Any other ideas on how to get this to work If there's a different signal I can use that other code won't override, that's fine (I don't care what the signal is, as long as I can catch it). Or perhaps there is something different I can do The program, at present, doesn't have much in the way of an internal shutdown mechanism. I'm using Python 2.5.1 on Fedora 8; the program does not need to be portable to Windows. - David (p.s. please post replies on the list; this email address doesn't work so I won't see any replies sent directly to me)
VIEWS ON THIS POST

98

Posted on:

Wednesday 7th November 2012
View Replies!

Newb question: underscore

What is this doing print >> fd, _(__doc__) I'm guessing line-splitting __doc__ into a list, but what's that leading underscore do
VIEWS ON THIS POST

119

Posted on:

Saturday 10th November 2012
View Replies!

Tips for load balancing multiple Python apps on dual/quad coreprocessors?

I'm looking for tips on how to load balance running multiple Python applications in multi-CPU environments. My understanding is that Python applications and their threads are limited to a specific CPU. Background: I have a Python utility that processes email ...
VIEWS ON THIS POST

91

Posted on:

Saturday 10th November 2012
View Replies!

Double underscore names

Double-underscore names and methods are special to Python. Developers are prohibited from creating their own (although the language doesn't enforce that prohibition). From PEP 0008, written by Guido himself: __double_leading_and_trailing_underscore__: "magic" objects or attributes that live in user-controlled namespaces. E.g. ...
VIEWS ON THIS POST

72

Posted on:

Sunday 11th November 2012
View Replies!

Highscores list

I'm writing a game that uses two functions to check and see if a file called highScoresList.txt exists in the main dir of the game program. If it doesn, it creates one. That part is working fine. The problem is ...
VIEWS ON THIS POST

76

Posted on:

Monday 19th November 2012
View Replies!

Questions about asyncore

Hi all I have been using my own home-brewed client/server technique for a while, using socket and select. It seems to work ok. The server can handle multiple clients. It does this by creating a new thread for each connection. ...
VIEWS ON THIS POST

65

Posted on:

Sunday 25th November 2012
View Replies!