Il giorno gio, 31/03/2011 alle 20.01 +0200, Giuseppe Penone ha scritto:
>         
>         (Assuming that indeed there's no way of using sockets in a
>         non-blocking
>         fashion - I'm totally ignorant about that) maybe having a
>         little process
>         created with multiprocessing would be simpler & more portable,
>         for you,
>         than using threading? I guess a single one is sufficient, so
>         the
>         overhead shouldn't be significant, even on Windows. Then, at
>         every
>         iteration of the main loop, the main process could check, from
>         a shared
>         Value (or Array), if there's something to open.
>         
>         (untested, sorry if I wrote something stupid)
> 
> Hi Pietro,
> the problem of having a single and independent process dedicated to
> the job of server is that the server would not be able to rise a
> minimized/hidden window as consequence of the situation "a new file
> open starts (user double click) unaware that the same file is already
> opened".


The server should not, that would be the job of the main process...

User: "Hey, program, open that file"
Main process1: starts, spawns the server through the multiprocessing
module
Server1: "Hey, main process, there is no open instance, have fun"
Main process1: "thanks", opens the file in a new window

later...

User: "Hey, program, open that file"
Main process2: starts, spawns the server through the multiprocessing
module
Server2: "hey, Main process2, there is an already open instance!"
Main process2: "OK, tell it to open that file!"
Server2: "Server1, could you please tell you friend Main process to open
that file?"
Server1: "Sure, Server2!"
(Main process2 & Server2 exit)
Server1: "Hey, Main process2, seems like the user wants to open that
file"
Main process1: as it does in every iteration of the main loop, scans for
new info from the Server1, finds a new filename to open, remembers it's
already opened in some window, rises that window.



(again, maybe I just missed something trivial, but at least that should
be able to avoid any additional misunderstandings)

(notice that _in any case_, with gtk, it is sane to play with GUI only
from one thread/process)

Pietro

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to