1

How to identify process is in frozen state in python

I am running python file on server on every mid night, Sometime its go into Frozen status. This is happens after 5 or 6 days?

Python script not take much memory or load during running, its takes 4 hrs if 120 documents for publish.

Following Steps:

  1. Run Python script custom.py
  2. After 1 hrs again run same python script when there is No same script in running.

If script is previous script is still in system then same script will not terminate.

But is process which running script goes into Froze or Zombie state, then next time script will not run because pervasion script still in system.

j08691
  • 204,283
  • 31
  • 260
  • 272
Vivek Sable
  • 9,938
  • 3
  • 40
  • 56

1 Answers1

2

If you want a script to be killed by timeout and you're on UNIX, you can use SIGALRM: Timeout on a function call

If you want to prevent several copies of the same script to be launched, there are several solutions. The simplest one is ps aux | grep. If it's not enough you may use filelock package https://pypi.python.org/pypi/filelock/ But from my experience it's still not stable. The best solution is to use sys-v ipc semaphores http://semanchuk.com/philip/sysv_ipc/. You may set undo flag to remove semaphore lock once the process terminates.

Community
  • 1
  • 1
Anton Zuenko
  • 721
  • 3
  • 13