In FreeBSD, ps
shows the command line in its output. So for a Python schript, this is the name of the interpreter followed by the name of the script. Both can be full paths or just program names.
So you can something like this:
import subprocess
import sys
scriptname = 'foo'
procs = subprocess.check_output(['ps', '-xa']).splitlines()
count = len([l for l in procs if 'python' in l and scriptname in l])
if count > 3:
sys.exit()