Skip to content

Instantly share code, notes, and snippets.

@strayge
Created September 18, 2019 11:15
Show Gist options
  • Save strayge/d70ef5960bf7acf2dd290ba0ca0c3aac to your computer and use it in GitHub Desktop.
Save strayge/d70ef5960bf7acf2dd290ba0ca0c3aac to your computer and use it in GitHub Desktop.
single mypy process for PyCharm
#!/Users/<username>/.local/share/virtualenvs/<folder>-<hash>/bin/python3
# -*- coding: utf-8 -*-
import subprocess
import os
current_pid = os.getpid()
s = subprocess.run('ps auxww | grep -F "/mypy" ', shell=True, stdout=subprocess.PIPE)
lines = s.stdout.decode().strip().splitlines()
pids = []
for line in lines:
while ' ' in line:
line = line.replace(' ', ' ')
parts = line.split(' ', 10)
pid, name = parts[1], parts[10]
#print(pid, name)
if pid != str(current_pid):
pids.append(pid)
pids_str = ' '.join(pids)
subprocess.run(f'kill {pids_str} > /dev/null 2>&1', shell=True)
import re
import sys
from mypy.__main__ import console_entry
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(console_entry())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment