Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 2nd, 2005, 7:59 AM   #1
dannyp
Newbie
 
Join Date: Jul 2005
Location: Philadelphia, PA
Posts: 11
Rep Power: 0 dannyp is on a distinguished road
Any Suggestions?

Hello,

I have an app using wxPyhton for the GUI. I click the Run button that triggers a function that opens a process and starts the command shell on Windows XP. Then I use the Input and Output streams to send a command( mycommand.exe) and what information returns from that I place in a multiline textctrl on my GUI screen. Everything works fine except, I have a Pause button and a Stop button to pause and stop execution. When I click Run, my Run button stays highlighted and the GUI is unresponsive until the process completes, so I can't press the Pause or Stop buttons. Any suggestions on how I should code this in order to be able to hit the run button and while the process is running the commands and updating the textctrl after every command(which it does now), make the GUI available to click the Stop or Pause buttons. Thanks
dannyp is offline   Reply With Quote
Old Aug 2nd, 2005, 2:32 PM   #2
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
What are you using for the inter-process communication? I'm not sure if wx.Process is available to you from wxPython, but if it is, you should not be using it. You should be using os.popen* or the subprocess module.
If you are using os.popen/subprocess, then chances are the non-blocking calls like os.system and os.popen are blocking because you're not holding on to the object. The destructor is being called because it's going out of scope, and that causes the blockage until the spawned application finishes.
If that's not your problem, post a testcase (_not_ the whole of your code, just a small enough, fully functional example that lets us isolate the problem easily).
Cerulean is offline   Reply With Quote
Old Aug 2nd, 2005, 3:24 PM   #3
dannyp
Newbie
 
Join Date: Jul 2005
Location: Philadelphia, PA
Posts: 11
Rep Power: 0 dannyp is on a distinguished road
Here is a the piece of offending code. I updated it to use the subprocess module, instead of wx.process. It runs the cmd2000.exe command once and then stops and freezes. Can you see what is wrong? Thanks

for x in range((int(self.nextOpenRow))):
            while True and not self.paused:
                self.test.SetGridCursor(0, 0)
                self.test.MakeCellVisible(0, 0)
                self.commandCell = self.test.GetCellValue(currentRow, 0,)
                self.cmdCell = self.test.GetCellValue(currentRow, 1,)
                self.ipCell = self.test.GetCellValue(currentRow, 2,)
                self.timestrCell = self.test.GetCellValue(currentRow, 3,)
                self.sleepCell = self.test.GetCellValue(currentRow, 4,)         
                y = 0
                p = Popen(["cmd.exe"], stdin=PIPE, stdout=PIPE)
                while y < int(self.timestrCell):
                    p.stdin.write("cmd2000.exe %s \"resdiag %s\"\n" % (self.ipCell, self.cmdCell))
                    self.stream = p.stdout
                    text = self.stream.read()
                    self.out.AppendText(text)
                    time.sleep((int(self.sleepCell)))                      
                    y += 1
                else:
                    self.test.MoveCursorDown(False)
                    currentRow = (currentRow + 1)
            else:
                self.run.Enable(True)
                return
dannyp is offline   Reply With Quote
Old Aug 2nd, 2005, 3:40 PM   #4
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
I really can't be sure as the example is a little too vague. `p` might be going out of scope and blocking. Please try and construct a minimal, fully working example that people can fiddle with like I suggested.
Cerulean is offline   Reply With Quote
Old Aug 2nd, 2005, 6:23 PM   #5
dannyp
Newbie
 
Join Date: Jul 2005
Location: Philadelphia, PA
Posts: 11
Rep Power: 0 dannyp is on a distinguished road
I can't post anything that will work, the program is really big spanning 3 different files. Also this is being written for a company, so I can't give out to much. I will play around with it, I was just seeing if you guys would notice something just from looking at this loop, this is whats doing the work, I can tell you what the variables are holding, not sure if that will help, but it won't hurt me to type them here if it doesn't. CommandCell and CmdCell are commands passed as args to cmd2000.exe, ipCell has an I.P address in it, timestrcell has a number which equals how many times to run a certain command, sleepcell is the number of seconds to sleep between each command. Thanks for trying.
dannyp is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC