-3

I am currently using psutil to do...

p = psutil.Process(pid)
p.kill()

...In an attempt to kill the process of one function (that I thought I was getting the pid of with):

os.getpid()

...Though this kills my entire manage.py runserver command and I have to restart the server.

Does anyone know what I can do here?

Mike Johnson Jr
  • 776
  • 1
  • 13
  • 32

2 Answers2

1

Functions do not have a process ID independent of the VM. Your question is meaningless.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

As Ignacio said, my question didn't make sense: "Functions do not have a process ID independent of the VM"

Though to answer the essence of my question: "how can i stop the execution of a function (infinite while loop) from outside of that function?"

We check a flag, e.g. a value set in a database. Helped by a kind stranger in #python in freenode

Mike Johnson Jr
  • 776
  • 1
  • 13
  • 32