Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Open running processes

Reply
Thread Tools

Open running processes

 
 
DeRRudi
Guest
Posts: n/a
 
      06-28-2005
Hi all,

I have a programm. In this program i've made the restriction that only
one instance can run at the time. (done with mutex).
Now i'd like it to open the running (make visible) instance when
someone want's to open it a second time.
Does anybody know how to do this? I hope you all understand what i
mean. My English isn't to good...

Greetz Rudi

 
Reply With Quote
 
 
 
 
DeRRudi
Guest
Posts: n/a
 
      06-28-2005
It is a wxWindow app. It is a kind of datamanager. it is possible to
minimize it to the systray.

hmm.. i've thought of an solution using memorymapping. see if it
works.. don't know if it is the 'best' or 'safest' way.. but ok.

Greetz.

ps. I'm always willing to learn!

 
Reply With Quote
 
 
 
 
DeRRudi
Guest
Posts: n/a
 
      06-29-2005
Well it doesnt work yet, but its gonna!
i've tested it with a little app. There is my main app (called it
server) wich contains a thread. This thread listens to a mm (memory
mapping) when an other program sets a flag
(finished_producing_event.set() ) it just calls self.iconize(false)

I'm not sure what pieces of code i have to post here.. posting all of
it makes it too large i believe

From server:


ID_MESSAGECH = wxNewId()

def EVT_RESULT(win, func):
win.Connect(-1, -1, ID_MESSAGECH, func)

class ResultEvent(wxPyEvent):

def __init__(self):
wxPyEvent.__init__(self)
self.SetEventType(ID_MESSAGECH)

class listener(Thread):
def __init__(self, frame):
Thread.__init__(self)
self.frame = frame
self.setDaemon(1)

self.stopped = False

#shared_memory = mmap.mmap (0, common.SHARED_MEMORY_SIZE,
common.SHARED_MEMORY_NAME)
#ready_to_consume_event = events.Win32Event
(common.READY_TO_CONSUME)
#finished_producing_event = events.Win32Event
(common.FINISHED_PRODUCING)

def run(self):
while not self.stopped:
try:
finished_producing_event.wait()
wxPostEvent(self.frame,ResultEvent(None))
except Exception,e:
print "Error: " , e

def stop(self):
self.stopped = True



within the frame:
[code:1:080343f1b1]
listen = listener(self)
listen.start()

EVT_RESULT(self, self.OnChange)

def OnChange(self, event):
shared_memory.seek(0)
tekstding = shared_memory.readline()
if(tekstding.strip() ==
"maximize"):
self.Iconize(False)
self.Show(False)
elif(tekstding.strip() ==
"minimize"):
self.Iconize(True)
self.Show(True)
self.panel.tekst.SetValue(tekstding)
[/code:1:080343f1b1]

Hope you can see now how it works! Greetz

 
Reply With Quote
 
DeRRudi
Guest
Posts: n/a
 
      06-30-2005
Well i want a external app to maximize and minimize my app.
And later on i want the external one to send some data. Thought this
would be the most easy (and fast) way!

Greetz

 
Reply With Quote
 
DeRRudi
Guest
Posts: n/a
 
      06-30-2005
> Tim Goldenwrote:

>
> Rudi. I, at least, am reading this via the mailing list, not
> via Usenet nor via Google. This means that if you don't put
> any kind of context in what you post, I have to guess at what
> you're responding to. (All I see is the exact text you typed,
> nothing else).
>
> Assuming that you're answering my question: why use mmap and
> not just two events? I understand what your overall plan is,
> and it looks like you have a way to solve it. It just seemed
> that you might be able to achieve the same thing with two
> events: one for maximize and one for minimize. Why would
> this be better? Well, only because it seems to me slightly simpler
> than one event and a separate mmap mechanism. But I've never
> done what you're doing, so I may well be completely wrong.
>
> TJG
>


Hi Tim,

I'm sorry did not realize it!
U are right! (i believe) at first i put in the minimize for testing.
I'm only using the maximize.
But it seemed handy to do it this way and beeing abled to send over
data from an other programm. That's what i want to use the mmap for.
Or am i missing something. because i'm not really seeing what your
point is. Because it is a complete different process what is calling
the maximize (or minimize) i can't just create an event and call it
(or can i?)

Greetz

 
Reply With Quote
 
DeRRudi
Guest
Posts: n/a
 
      06-30-2005
> Tim Goldenwrote:

> If you wanted to send over arbitrary data from another application,
> then this is certainly a way to do it. (Another way might be to use

a
> Windows pipe, for example). My point was only that if you are

signalling
> an event as a wake-up call plus an atom of extra information saying


> "max" or "min", and you weren't considering any expansion of this
> vocabulary to include other commands, then two distinct events might


> be simpler, one signalling "maximize", the other "minimize".
>
> Please don't take this as any criticism of your work: there's no

one
> right design decision here; I was merely curious as to the reasons
> behind yours.
>
> TJG
>


Thanx for thinking with me! It really helps to have some other
opinions! It might look simpeler to make two distinct events. But
reading out the mm is really easy to do. So i didn't make more events
for maximizing and minimizing. But further on i'm gonna use it. I
think by now i have all the thing's i need to solute my problems.
Thnx

Rudi

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controlling processes and what to "feed" other processes Marc Heiler Ruby 1 05-24-2009 05:37 PM
Worker Processes Running counter? Rusty Shackleford ASP .Net 0 10-05-2005 01:54 PM
Generating a trigger signal to align two processes running on different clocks Divyang M VHDL 4 02-17-2005 09:17 PM
Running Processes in XP Jane Slee Computer Support 3 01-17-2004 07:02 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments