On Monday, June 8, 2015 at 1:08:07 AM UTC+2, Ned Deily wrote: > In article <11e093d5-b78e-4ac6-9a7f-649cb2c2c...@googlegroups.com>, > Andrei wrote: > > Alright, I have had some development in > > http://stackoverflow.com/questions/30694560/detect-if-specific-python-app-inst > > ance-is-already-running and can prevent running multiple instances of the > > same app/script (by lockf), but I still need to identify which Python.app > > instance is running certain script. I guess it's more Cocoa-related > > question > > but I hope someone had same problem with tkinter etc. > > Can you give a more complete explanation of the goal, i.e. what you are > trying to end up with here, rather than the steps you are taking to get > there? It's not at all clear to me what your goal is and the cumbersome > steps you find you have to take suggest that you might be going down the > wrong path. OS X apps usually don't have to resort to such hacks. If > you haven't already, make sure you have looked at the "Information > Property List Key Reference" for OS X (and iOS) apps. For instance, key > LSMultipleInstancesProhibited *might* be useful if you really only want > to ensure that there is only instance of an app launched. > > https://developer.apple.com/library/mac/documentation/General/Reference/I > nfoPlistKeyReference/Articles/LaunchServicesKeys.html > > -- > Ned Deily
Hi Ned, Thanks for your reply! The problem is a bit tricky as I see it. Multiple instances of Python.app needs to be run since it may run different tkinter apps etc. What I need is rather simple: 1. start app, mark the instance with tkinter app name 2. start another one, detect that the same instance is already running and identify it 3. focus on the first instance, close the second one I have solved it with a lock file and a pid file (I guess I could use just one file for both jobs, but didn't have time to test it yet). I believe it could be done without files, i.e. by setting some public attributes on app instances. I could probably also use OS X key storage for this but it gets too similar to the file approach and I am not sure if it's any better. I may be wrong in my thinking. If so, just let me know :) Thanks, Andrei -- https://mail.python.org/mailman/listinfo/python-list