Determine if only one instance is running

From Rosetta Code
Task
Determine if only one instance is running
You are encouraged to solve this task according to the task description, using any language you may know.

This task is to determine if there is only one instance of an application running.

Visual Basic

Language Version: 6

 Dim onlyInstance as Boolean
 onlyInstance = not App.PrevInstance

Python

Language Version: 2.5

without `inspect`

import sys, os

def isOnlyInstance():
    frame = sys._getframe()
    while frame.f_back:
        frame = frame.f_back
    if not os.system('(( $(ps -aef | grep python | grep \'[' + frame.f_code.co_filename[0] + \
    ']' + frame.f_code.co_filename[1:len(frame.f_code.co_filename)] + '\' | wc \
    -l) > 1 ))'):
        return 0
    else:
        return 1

with `inspect`

import inspect, os

def isOnlyInstance()
    frame = inspect.currentframe()
    while frame.f_back:
        frame = frame.f_back
    if not os.system('(( $(ps -aef | grep python | grep \'[' + frame.f_code.co_filename[0] + \
    ']' + frame.f_code.co_filename[1:len(frame.f_code.co_filename)] + '\' | wc \
    -l) > 1 ))'):
        return 0
    else:
        return 1