473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tk and raw_input segfault

Python newbie disclaimer on

I am running an app with Tkinter screen in one thread and command-line
input in another thread using raw_input(). First question - is this
legal, should it run without issue? If not can you point me to a
description of why.

While updating objects on the screen I get a segfault after an
indeterminate number of updates. It doesn't seem to matter how quickly
the updates occur, but it does segfault faster when there are more
objects on the screen ( as I said failure time seems to have a random
factor added to it ).

Commenting out the raw_input() makes problem go away. I can schedule
as many updates as I wish without error. And it doesn't seem to matter
if I actually hit any keys for raw_input(), it can just sit there.

I have read other posts about readline library failures with Esc O M
sequences and could not recreate those failures.

This happens on 2 separate machines

1st: development workstation
tk-8.4.6-28
tcl-8.4.6-23
Python 2.3.3 (#1, Feb 5 2005, 16:30:27)
[GCC 3.3.3 (SuSE Linux)] on linux2
Linux <name deleted> 2.6.5-7.151-smp #1 SMP Fri Mar 18 11:31:21 UTC
2005 x86_64 x86_64 x86_64 GNU/Linux

2nd: target machine
tk-8.4.6-37
tcl-8.4.6-26
Python 2.3.3 (#1, Apr 6 2004, 01:47:39)
[GCC 3.3.3 (SuSE Linux)] on linux2
Linux <name deleted> 2.6.4-52-default #1 Wed Apr 7 02:08:30 UTC 2004
i686 i686 i386 GNU/Linux

I have tried to simplify the code as much as possible to make error
more visible( no actual updates of the screen etc ) I've uncommented
the "after" code line so it fails much more rapidly. I know its ugly
repeatedly scheduling the after but, the same code runs without the
raw_input, and it shows the error more readily.

To see the error start the code and click the button repeatedly until
it segfaults. It will still segfault if you remove the 'command'
funtion and call update dirctly - it just takes a bit longer and your
wrist will probably get tired.

Thanks in advance for any responses.
------------------------------------------

from Tkinter import *
from time import sleep
import thread

class Test(Frame):
def __init__(self, parent=None):
Frame.__init__( self, parent, bg='white')

# Button Definition: CLEAR ALL OUTPUTS
caB = Button( self, text='CLEAR ALL\nOUTPUTS',\
#command = (lambda: self.update()) )
command = (lambda: self.command()) )
caB.pack()
self.updateCoun t = 0
self.commanded = 0
self.update()

def command( self ):
self.commanded = 1
self.update()

def update( self ):
self.updateCoun t += 1
print 'updatin... num = ', self.updateCoun t
self.after( 1, self.update )

def test():
root = Tk()
root.geometry(' 640x480')
Test().pack()
root.mainloop()

if __name__ == '__main__':
scanTID= thread.start_ne w_thread( test, () )
sleep(1)

while True:
f= raw_input()
print 'f=', f
sleep(1)

Jul 19 '05 #1
0 1811

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
3140
by: Nathaniel Echols | last post by:
I've written a function in C to perform protein sequence alignment. This works fine in a standalone C program. I've added the necessary packaging to use it in Python; it returns three strings and an integer. However, as soon as the function is complete, I get a segfault and the interpreter dies. If I run Python interactively, just...
6
1975
by: Stefan Behnel | last post by:
Hi! In Python 2.4b3, the deque is causing a segfault on two different machines I tested on. With deque, my program runs fine for a while (at least some tens of seconds up to minutes) and then suddenly segfaults. I'm sorry I can't tell exactly when, but I'm running an application that uses a few hundred deques where elements are...
2
7225
by: J. W. McCall | last post by:
I'm working on a MUD server and I have a thread that gets keyboard input so that you can enter commands from the command line while it's in its main server loop. Everything works fine except that if a player enters the 'shutdown' command, everything shuts down, but the input thread is still sitting waiting for enter to be pressed for...
1
2935
by: JerryKreps | last post by:
Hi, folks -- I'm a Python pup. As you can see from the session copied at the end of this post, I have the latest version of Python, and I've been using the Editor-Shell of the latest version of Boa Constructor while going through some Python tutorials. Everything was working as expected until I started using the raw_input built-in...
10
1931
by: name | last post by:
When I started testing the algorithms for my wrap program, I threw together this snippet of code, which works quite well. Except that it (predictably) segfaults at the end when it tries to go beyond the file. At some point, I tried to mend that behavior using feof() but without success. The functionality is not harmed, but this has started...
21
8725
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would like to include the ability to edit an existing value (drawn from an SQLite table) using a DOS console Python app, but my gut
17
4171
by: Stuart McGraw | last post by:
In the announcement for Python-2.3 http://groups.google.com/group/comp.lang.python/msg/287e94d9fe25388d?hl=en it says "raw_input(): can now return Unicode objects". But I didn't see anything about this in Andrew Kuchling's "2.3 What's New", nor does the current python docs for raw_input() say anything about this. A test on a MS Windows...
7
2028
by: Mike Kent | last post by:
It's often useful for debugging to print something to stderr, and to route the error output to a file using '2>filename' on the command line. However, when I try that with a python script, all prompt output from raw_input goes to stderr. Consider the following test program: === Start test.py === import sys
8
5278
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples. (Sorry, long email) The first two examples are behaving normal, the thirth is strange....... I wrote the following flabbergasting code:...
0
7478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.